Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

after i click "coin" it destroys itself and clones but the clone is just a part without any script?

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

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.