I don’t know if I am going crazy or what. I don’t understand why this on/off button thing doesn’t work. Here’s the script
script.Parent.ShadowsButton.MouseButton1Click:Connect(function()
local Toggled = true
if Toggled == true then
script.Parent.ShadowsButton.Text = "On"
script.Parent.ShadowsButton.BackgroundColor3 = Color3.new(0.333333, 1, 0)
Toggled = false
elseif Toggled == false then
script.Parent.ShadowsButton.Text = "Off"
script.Parent.ShadowsButton.BackgroundColor3 = Color3.new(1, 0, 0)
Toggled = true
end
end)
Citrozi
(Citro)
January 28, 2022, 3:56am
#2
Every time you click the button, it will set toggled to true. Try putting the variable Toggled outside of the function
1 Like
Could always remove the toggled variable and just check the text. So if text = “On” go Off, etc etc.
1 Like
Haha thanks for helping me refresh my brain I was sleepy lol
Dr_Bloomfield:
always
The previous reply would of worked as well like, @Citrozi said in the previous post you were resetting the value of toggled everytime the function was ran, moving it to the outside would fix it. Probably the more efficient way as well.