So I am trying to get my GUI to have a animated open to it and instead of having a text button to open this with I am using ClickDetector and it's not really working, here's the script I'm using to do this:
wait (1) local on=false local f=script.Parent.Parent.Frame function click () if on == false then on = true f:TweenPosition(UDim2.new(0.35,0,0.35,0),"Out","Bounce",1) else f:TweenPosition(UDim2.new(-0.35,0,0.35,0),"Out","Bounce",1) if on == true then on = false end end end script.Parent.MouseButton1Click:Connect(click)
Please respond when you have the answer to this! I
You want to use MouseClick since MouseButon1Click is not a valid member of ClickDetector. I am not sure why you put a wait(1) at the start of your script but for the sake of keeping your script as it is, here's my fix:
wait (1) local on=false local f=script.Parent.Parent.Frame function click() print("Detected click") if on == false then on = true f:TweenPosition(UDim2.new(0.35,0,0.35,0),"Out","Bounce",1) else f:TweenPosition(UDim2.new(-0.35,0,0.35,0),"Out","Bounce",1) if on == true then on = false end end end script.Parent.MouseClick:Connect(click)
You put the script under ClickDetector so that script.Parent = ClickDetector.
To confirm that the click() function runs you add a print inside it.
*Edit
For gui's you're supposed to use either a TextButton or an ImageButton. Once you add either one of those, you can use your initial line (script.Parent.MouseButton1Click:Connect(click)) in the local script under it. Here's an edit of your script for using a TextButton or MouseButton with GUIs.
wait (1) local on=false local f=script.Parent.Parent.Frame function click() print("Detected click") if on == false then on = true f:TweenPosition(UDim2.new(0.35,0,0.35,0),"Out","Bounce",1) else f:TweenPosition(UDim2.new(-0.35,0,0.35,0),"Out","Bounce",1) if on == true then on = false end end end script.Parent.MouseButton1Click:Connect(click)
Here's how it should look like in your explorer: https://prnt.sc/vggbde (ScreenGui --> TextButton --> LocalScript)