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

Why doesn't this Debounce work?

Asked by 9 years ago

I am making a Script when a Player touches a part, and it gives them 1 Player Point, but it gives them 2-4 Player Points when they touch it, not 1. Does anyone know to fix it?

local Model = script.Parent

print 'PlayerPart Script running!'
--PointsPart--
local egg = script.Parent
local ModelCopy = Model:Clone()
debounce = false

egg.Touched:connect(function(part)
local g = game.Players:GetPlayerFromCharacter(part.Parent)
if debounce then return end
if part:IsA("Part") and (g) then --So, basically, when a player touches this part, they get 1 player point.
pps = game:GetService("PointsService")
if pps:GetAwardablePoints() >= 1 then --change if possible
    pps:AwardPoints(g.userId, 1) 
debounce = true
wait(5)
debounce = false
end
egg:remove()
wait(100)
ModelCopy.Parent = game.Workspace
end
end)

--Script made by me--
--THIS REQUIRES A POINTS AVALIBLE GUI--                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                 print ('stopthecakehate made the player points part script')

1 answer

Log in to vote
0
Answered by 9 years ago

Line 12.

local Model = script.Parent

print 'PlayerPart Script running!'
--PointsPart--
local egg = script.Parent
local ModelCopy = Model:Clone()
debounce = false

egg.Touched:connect(function(part)
local g = game.Players:GetPlayerFromCharacter(part.Parent)
if debounce then return end
debounce = true --set to true before you continue with the rest
if part:IsA("Part") and (g) then --So, basically, when a player touches this part, they get 1 player point.
pps = game:GetService("PointsService")
if pps:GetAwardablePoints() >= 1 then --change if possible
    pps:AwardPoints(g.userId, 1) 
wait(5)
debounce = false
end
egg:remove()
wait(100)
ModelCopy.Parent = game.Workspace
end
end)

--Script made by me--
--THIS REQUIRES A POINTS AVALIBLE GUI--
0
It won't give out Player Points or remove the Egg now though, I think it broke it ScriptingHelpersALT 20 — 9y
0
Nvm it works, sorry thank's ScriptingHelpersALT 20 — 9y
Ad

Answer this question