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)
4 comments
This sadly did not work, the output did not say "Detected click" either.
Are you getting any errors? Because this is working fine for me. This is how it should be in your workspace: https://prnt.sc/vgg31p
Copy all my script and replace it with yours.
That's what I did... and it's still not working. Contact me through my Discord: Apple King#4016