This script sometimes gives up to 50 player points per touch but its only set to give 10. I know why but I dont know how to fix it. Here is the code.
local Part = script.Parent Part.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if part:IsA("Part") and (player) then local points = game:GetService("PointsService") if points:GetAwardablePoints() >= 0 then points:AwardPoints(player.userId, 10) wait() script:remove() wait(5) end end end)
I'm assuming your problem is that both legs are touching the part at the same time, and possibly walking on and off the part. Add some sort of debounce into your code like so:
local Part = script.Parent local deb = false --set the variable Part.Touched:connect(function(part) if deb == false then --make sure it's false, so you don't spam the button deb = true --set it to true so it won't run the code again until it's false local player = game.Players:GetPlayerFromCharacter(part.Parent) if part:IsA("Part") and (player) then local points = game:GetService("PointsService") if points:GetAwardablePoints() >= 0 then points:AwardPoints(player.userId, 10) wait() script:remove() wait(5) end end wait(.5) --half a second before they can touch the part again for more points deb = false --enabling the code again end end)
Hope I helped!