Hello, I'm having a problem cloning a model after destroying it, here is my code.
amount = 1 banana = game.Workspace.Banana banana.Archivable = true function onTouched(Banana) local h = Banana.Parent:findFirstChild("Humanoid") if (h~=nil) then local thisplr = game.Players:findFirstChild(h.Parent.Name) if (thisplr~=nil) then local stats = thisplr:findFirstChild("leaderstats") if (stats~=nil) then local score = stats:findFirstChild("Bananas") if (score~=nil) then score.Value = score.Value + amount script.Parent:Destroy() wait(3) script.Parent:Clone() end end end end end script.Parent.Touched:connect(onTouched)
You Cannot clone anything after destroying it. If you have destroyed it, the script doesn't know what you're telling it to clone. if u want the clone to appear after you've destroyed the previous part then do this
amount = 1 banana = game.Workspace.Banana banana.Archivable = true function onTouched(Banana) local h = Banana.Parent:FindFirstChild("Humanoid") if (h~=nil) then local thisplr = game.Players:FindFirstChild(h.Parent.Name) if (thisplr~=nil) then local stats = thisplr:FindFirstChild("leaderstats") if (stats~=nil) then local score = stats:FindFirstChild("Bananas") if (score~=nil) then score.Value = score.Value + amount local cloned = script.Parent:Clone() script.Parent = cloned script.Parent:Destroy() wait(3) cloned.Parent = game.Workspace --//This is if it is a server script. If it is a local script then replace this line with **cloned.Parent = workspace** end end end end end script.Parent.Touched:Connect(onTouched)