It sounds simple right? Well I have tried time over time. I want to click on a screengui and when I click on it the decal changes to a light switch that is on and the light comes on. Than I want to click it again and it change to the off light switch. Anybody mind helping me write the script it should be very simple.
P.S. It is an ImageButton on the Screengui that changes decals.
This is what I have so far:
On=false function onClicked() if On then On=false else On=true while On do script.Parent.Image = Image.new("rbxassetid://173364351") wait(0.1) end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
That above is the enabler but is there a way to make it so for example I can disable it and enable. I guess I am just kind of confused if someone can clear it up for me.
First of all, there are alot of errors here.
if On then On=false else
This, this is just, well, confusing too look at XD.
while On do
has been changed to while On==true do
because that doesn't make sense either
You never do Image.new()
, thats not even a thing, you just do script.Parent.Image = "http://www.roblox.com/asset/?id= image id"
.
Finally, the worst error here. script.Parent.ClickDetector.MouseClick:connect(onClicked)
When you click a GUI button, its not a ClickDetector... thats for a part, not for a GUI. And you don't use MouseClick
on a GUI, you use MouseButton1Down
.
Please check your scripting or learn some scripting.
Your welcome
On=false function onClicked() if On == false then On = true while On == true do script.Parent.Image = "http://www.roblox.com/asset/?id=173364351" wait(0.1) end end end script.Parent.MouseButton1Down:connect(onClicked)