#I cant figure this out

1 messages · Page 1 of 1 (latest)

viral mauve
#

local Coins = workspace:WaitForChild("Coins")

local touched = {}

for _, Coin : Part in pairs(Coins:GetChildren()) do
if Coin:IsA("BasePart") then
Coin.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local leaderstats:Folder = Player:WaitForChild("leaderstats")
if leaderstats then
if touched[Coin.Name] then return end
touched[Coin.Name] = true
leaderstats.Coins.Value += 1

                game.Debris:AddItem(Coin, .1)
            end
        end
    end)
end

end

when I collect more coins it doesn't work

balmy tartan
#

the ": Part"

viral mauve
#

okay

#

let me test

#

still wont work it wont me collect more coin after collecting one coin

balmy tartan
# viral mauve local Coins = workspace:WaitForChild("Coins") local touched = {} for _, Coin :...

local coins = workspace:WaitForChild("Coins")

local debris = game:GetService("Debris")

local touched = {}

for _, coin in coins:GetChildren() do

if coin:IsA("BasePart") then
coin.Touched:Connect(function(hit)
  local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

if plr then

--leaderstats:Folder is invalid syntax.
local leaderstats = plr:WaitForChild("leaderstats")

if leaderstats then
  if touched[coin.Name] then return end

touched[coin.Name] = true

leaderstats.Coins.Value += 1
debris:AddItem(coin, 0.5)
end
end
end)
end```
#

works?

viral mauve
#

nope

#

i fixed it tho nice

#

so like

#
if touched[plr.UserId] then return end

                    touched[plr.UserId] = true

                    leaderstats.Coins.Value += 1
                    
                    debris:AddItem(coin, 0)
                    task.wait(0.01)
                    
                    touched[plr.UserId] = false
#

i have to make the debounce false or it would'nt work

tepid fable
#

you can use destroy