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

Is there someway to make the MouseButton1Click event fire just one time ?

i'm making a teleport room for my roblox game, i used a MouseButton1Click event that will add the player to the table, but something went wrong, i have just clicked the Gui once but the event fire a lot of times and insert a lot of thing to the table (my roblox username), how can i fix it ?

1 answer

✓ Accepted answer

this is what i can do, tell me if there is something wrong.


gui.MouseButton1Click:Connect(function(plr)
       if not plr:FindFirstChild("HasJoined") then
             local hasjoined = Instance.new("BoolValue", plr)
            hasjoined.Name = "hasjoined"
             
             if not plr:WaitForChild("HasJoined").Value == true then
                     hasjoined.Value = true
                    //put the rest of your script here
             end
      end
end)

3 comments

0

Sorry about my comment lol I was about to state you that not will not detect nil, but it looks like false and nil are labelled as non-true, your script is absolutely correct

0

sorry im dumb at coding bc i have just joined study scripting for like some months but can you please explain it :D????

1

well, thanks a lot for solving it for me but now i realize that we just need to use a local script instead and the error fixed, anyway, thanks for your answer 10000000 times !

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