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

Why doesn't this Debounce work?

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

✓ Accepted answer

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--

2 comments

0

It won't give out Player Points or remove the Egg now though, I think it broke it

0

Nvm it works, sorry thank's

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