01 | script.Parent.Touched:Connect( function (hit) |
02 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
03 | local debounce = false |
04 |
05 | if plr then |
06 | plr.Character.HumanoidRootPart.CFrame = CFrame.new(- 81.2 , 26 , - 10.6 ) |
07 | if not debounce then |
08 | debounce = true |
09 | plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 10 |
10 | wait( 15 ) |
11 | debounce = false |
12 | end |
13 | end |
14 | end ) |
I've made a debounce script to stop giving player points when it touched the part. (example, I want to give player 10 points, but It gives me 40)
any help is appreciated :]
You should put the debounce variable outside
01 | local debounce = false |
02 | script.Parent.Touched:Connect( function (hit) |
03 | if game.Players:GetPlayerFromCharacter(hit.Parent) then -- You can do this as well |
04 | plr.Character.HumanoidRootPart.CFrame = CFrame.new(- 81.2 , 26 , - 10.6 ) |
05 | if not debounce then |
06 | debounce = true |
07 | plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 10 |
08 | wait( 15 ) |
09 | debounce = false |
10 | end |
11 | end |
12 | end ) |
script.Parent.Touched:Connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local debounce = false
01 | if plr then |
02 | plr.Character.HumanoidRootPart.CFrame = CFrame.new(- 81.2 , 26 , - 10.6 ) |
03 | if (debounce = = false ) then |
04 | debounce = true |
05 | if (hit.Parent.Name = = "Your Name" ) then |
06 | plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 40 |
07 | else |
08 | plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 10 |
09 | wait( 15 ) |
10 | debounce = false |
end end end end)