my code is
script.Parent.ClickDetector.MouseClick:Connect(function(player) local PlayerPoints = player.leaderstats.Points local coin = game.Workspace.Coin PlayerPoints.Value = PlayerPoints.Value + 1 coin:Destroy() wait(3) local coin = coin:Clone() coin.Parent = game.Workspace end)
i alr have leader stats
it is because clone is already removed, you can put a replacement on ReplicatedStorage and do
local Coin = game:GetService("ReplicatedStorage").Coin game:GetService("Players").PlayerAdded:Connect(function(player) local debounce = false local CoinClone = Coin:Clone() CoinClone.Parent = game.Workspace local function SpawnCoin() player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1 game.Workspace.Coin:Destroy() wait(3) local CoinClone1 = Coin:Clone() CoinClone1.Parent = game.Workspace end script.Parent.ClickDetector.MouseClick:Connect(SpawnCoin) end
I hope this works? I think there is some better solution, you could check out https://devforum.roblox.com/t/creating-a-coin-collection-system/559120 because my poor scripting