Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help me on if clicked is true?

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

✓ Accepted answer

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

6 comments

0

thanks :)

0

No prob :P

0

Wait, I realized a mistake...is the script inside a click detector?

0

Or wait, is it in a gui?

0

Obviously a Gui. It's named ShopFrame

0

Lol, sorry. I'm not thinkin straight today.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.