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

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

Asked by 3 years ago

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

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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

01gui.MouseButton1Click:Connect(function(plr)
02       if not plr:FindFirstChild("HasJoined") then
03             local hasjoined = Instance.new("BoolValue", plr)
04            hasjoined.Name = "hasjoined"
05 
06             if not plr:WaitForChild("HasJoined").Value == true then
07                     hasjoined.Value = true
08                    //put the rest of your script here
09             end
10      end
11end)
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 Xapelize 2658 — 3y
0
sorry im dumb at coding bc i have just joined study scripting for like some months but can you please explain it :D???? ninjaty2003 8 — 3y
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 ! ninjaty2003 8 — 3y
Ad

Answer this question