When I play my game all the PP gets stacked up and never deletes. How do you fix it? I have the script inside a brick and when you touch it, it gives you 3 player points.
local PointsService = game:GetService("PointsService")
local db = false local dbTime = 3
function onTouched(hit) if not hit.Parent:FindFirstChild("Humanoid") or db then return end local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then db = true PointsService:AwardPoints(player.userId, 3) wait() wait(2) script.Parent:Destroy() db = false end end
script.Parent.Touched:connect(onTouched)
if you want a part that gives 3 player points, put this in the part (NORMAL SCRIPT)
debounce = true script.Parent.Touched:connect(function(hit) --Part gets touched, we call the toucher "hit" player = hit.Parent:FindFirstChild("Humanoid") --Checks for Player if player ~= nil and debounce==true then --There must be a Humanoid and debounce must be true. Then do... debounce == false --Avoids a continuous repeat game:GetService("PointsService"):AwardPoints(hit.userId, 3) --Awards 3 Points to toucher else --If it's not a player then... script.Parent:Destroy() --Completely remove the brick end wait(10) --Change this 10(seconds) to whatever you want(Seconds) debounce = true --The part can be touched again. end --This should work, as long as it's in a NORMAL SCRIPT. Remember to clone it...