why is the script causing spam even with a Debounce on it?
Asked by
4 years ago Edited 4 years ago
hello. So, I created a script that adds "+1" to the money of the player who touched a coin.
apparently, the script is right, but some coins that the player touches (I don’t know if it’s a glitch or something I forgot to put in the script), instead of adding "+1" to your money, a much larger number is added (+3 or +4 ...)
script:
01 | local player = game.Players.LocalPlayer |
02 | player.CharacterAdded:Wait() |
04 | local cointouchevent = game:GetService( "ReplicatedStorage" ):WaitForChild( "Slotdata" ):WaitForChild( "CoinDestroy" ) |
05 | local hum = player.Character:WaitForChild( "Humanoid" ) |
06 | pointsvalue = player:WaitForChild( "leaderstats" ):WaitForChild( "Points" ) |
08 | local sound = Instance.new( "Sound" ,player.PlayerGui) |
10 | sound.MaxDistance = 100 |
14 | hum.Touched:Connect( function (hit) |
15 | if hit.Name = = "Coin" then |
20 | pointsvalue.Value = pointsvalue.Value + 1 |
It is as if there was no Debounce (which I put to avoid spam.