Jul 11, 2024
script.Parent.MouseButton1Click:Connect(function()
to detect button clicks.script.Parent:SetAttribute('Toggle', not script.Parent:GetAttribute('Toggle'))
script.Parent.Text = (script.Parent:GetAttribute('Toggle') and 'On' or 'Off')
function toggleLight(value)
game.Workspace.Light.BrickColor = value and BrickColor.new('New Yeller') or BrickColor.new('Medium stone grey')
end
toggleLight
function within the button click event:
toggleLight(script.Parent:GetAttribute('Toggle'))
toggleLight
outside the event to maintain the state on game start.