Hello, I need help when I touch the coin nothing happens is there something wrong with the script?
im not that good in for loops but can someone tell me what i did wrong?
local coin = game:GetService("CollectionService")
local storage = game:GetService("ReplicatedStorage")
debounce = false
for i, Coins in pairs(coin:GetTagged("Coins")) do
Coins.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if debounce == false then
if humanoid then
debounce = true
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
player.leaderstats.Coins.Value += 1
storage.CoinRemoteEvent:FireClient(player)
wait(120)
debounce = false
end
end
end)
any help is appreciated!