I am making 3d 1 Dollar bill in Roblox Studio, and there is a problem with cloning it. I made a touched event connected to the dollar and tried attempting to make it so once you step on the bill you gain 1 "Money" for the leader stats. It works all well until the clone, once you step on it you destroy the bill but then after 2 seconds the bill respawns so you can get more money but.. The bill only respawns and it does not function again as the script tells it to. Why is this happening?
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local MoneyCollected = Instance.new("IntValue")
MoneyCollected.Name = "Money"
MoneyCollected.Parent = leaderstats
local OneDollar = game.Workspace.OneDollar
local Onedollar = OneDollar:FindFirstChild("Hitbox")
local OneDollarC = OneDollar:Clone()
local OnedollarC = Onedollar:Clone()
Onedollar.Touched:Connect(function(hit)
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1
Onedollar:Destroy()
OneDollar:Destroy()
wait(2)
OneDollarC.Parent = game.Workspace -- puts it in the workspace but the script doesn't work anymore, why?
end)
end)
-SqmetImesDev

1 comment
Nothing works now, and there is a underline on hitfunc on line 23. Also, its not giving me the error.