Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Help me on if clicked is true?

Asked by 9 years ago

I'm testing if when this certain button gets clicked it will close the one that is showing up now. But when i click it it shows for like half a second then disappear.

while wait(.1) do
    if script.Parent.Parent.ShopFrame["Zombie Magnitizer"].MouseButton1Click then
        script.Parent.Visible = false
    end
end

3 answers

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

The reason it's doing that is because you used the function wrong. If you're using a gui button, then the function is correct, but you still need to set it up correctly. If you're using a brick, then useMouseClick, and you need to make sure it's used in a ClickDetector. Try setting it up like this:

script.Parent.Parent.ShopFrame["Zombie Magnitizer"].MouseButton1Click.MouseClick:connect(function()
        script.Parent.Visible = false
    end
end)

This should work. If there's something else you need help with, let me know in the comments. Hope this helped :P

0
thanks :) Anthony9960 210 — 9y
0
No prob :P dyler3 1510 — 9y
0
Wait, I realized a mistake...is the script inside a click detector? dyler3 1510 — 9y
0
Or wait, is it in a gui? dyler3 1510 — 9y
View all comments (2 more)
0
Obviously a Gui. It's named ShopFrame aquathorn321 858 — 9y
0
Lol, sorry. I'm not thinkin straight today. dyler3 1510 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Click isn't a property; It's an event. There's a way to check if a click is true using coroutines, but it's very inefficient, so it's better you use it as an event calling an anonymous function instead.

script.Parent.Parent.ShopFrame["Zombie Magnitizer"].MouseButton1Click:connect(function()
script.Parent.Visible = false
end
end)
Log in to vote
0
Answered by
Xetrax 85
9 years ago

I just want to add onto dyler3's answer, with a short edit:

script.Parent.Parent.ShopFrame["Zombie Magnitizer"].MouseButton1Click.MouseClick:connect(function()
    script.Parent.Visible = not script.Parent.Visible   -- I assume you want this to be a toggle button? if so, then this should do, it reverses the Visible property each time its clicked, meaning if Visible is true, then it changes it to false and vice versa.
    end
end)

Meh, change it if you wish, I just wanted to add in a little more complexity... :P Regards, Xetrax

Answer this question