I got a part, that if you touch it, you get points:
script.Parent.Touched:Connect(function(hit) if hit and hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) wait(1) player.leaderstats.Money.Value += 10 player.leaderstats.Level.Value += 1 end
end)
But if you keep touching the part you still get money, but i want it to happen just once,what i should add?
You can add debounce,
local waittime = 2 local isTouched = false script.Parent.Touched:Connect(function(hit) if hit and hit.Parent:FindFirstChild("Humanoid") and not isTouched then isTouched = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) wait(1) player.leaderstats.Money.Value += 10 player.leaderstats.Level.Value += 1 wait(waittime) isTouched = false end end)
Have not tested the code, tell me if there are any errors