2 Clicks button error on a Gui

So I’m making a script that if you don’t have sufficient money the GUI will be invisible and inactive, but the problem is that it only disappears when I click 2 times, if I click 1 time it would not disappear, so I’ll appreciate your help if you can say something down here :slight_smile:

Here’s the script:

Also, I can’t use RemoteEvents because I have something that doesn’t let me use RemoteEvents ( only on these types of GUI ) but the rest is good!

Make it invisible/inactive by default?

Perhaps you could use the GuiButton.Activated event to detect double clicks. I haven’t tested this, but it could possibly work.

Nah man. It already double clicks, but he wants it to disappear after 1 click.

Sidenote to OP: one line 6 you could have used the optionlocalprice variable :smiley:

I’m a bit confused, why are you looping through all the players and checking their cash values???

you can’t really change other clients values from a localscript lol

Instead of combining the buying part of the script and hiding the gui part of the script together (which you can do but for this example im not going to) you can do this:


(THIS IS ONLY FOR REFERENCE AND AN EXAMPLE, NOT AN ACTUAL SCRIPT SO IT’S GOING TO BE MESSY AND WON’T WORK IF YOU COPY AND PASTE)


script.parent.mouseclick:connect(function()
~buying item script here~
end)


While true do
wait()
if player.coin.value <= 19 then
~insert hiding the gui script here~
end
end


why do you check all of the players in the player list?

also the = not segment is so incessant, like for the visible ones just say …visible=false…