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
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
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)
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