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

Help with debounce?

Asked by 9 years ago

I made a script that determines a player distance to a brick and then I added a debounce to it but it didn't work.How could I fix it so it can work and so it won't spam it on the players Gui? Please show how you managed to fix it.

while true do
    wait(0.1)
for Number,Player in pairs (game.Players:GetChildren())do--Gets all the Players in the PlayerFolder
---------------------Vairibles---------------------------
    Part = script.Parent
    Guis = script.Guis
----------------------------------------------------------  
Near = false -- Near is a debounce set to false
        Distance = (Player.Character.Torso.Position - Part.Position).magnitude --Gets the Characters Torso's postion and the postion of the part

        if Distance < 6 and Near == false--If the distance is lower the 6 then it will do the thing below
then
Near = true
for Num,AllGuis in pairs (Guis:GetChildren()) do--Gets the guis from the folder
ClonedGuis = AllGuis:Clone()--Clones the Guis
ClonedGuis.Parent = Player.PlayerGui -- After the guis are cloned then their put inside the Player's GUI folder
end
Near = false
end
end
    end



0
You need to add a wait somewhere in side of the if statement. Aethex 256 — 9y
0
But if I do other players won't be able to get the GUIs. kevinnight45 550 — 9y

Answer this question