I have a clone character on spawn script but it gives me a "attempt to index local 'd' (a nil value)" error. How would I fix this? Here is my server script:
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) wait(5) local d = char:Clone() d.Parent = game.Workspace end) end)
Try this!
game.Players.PlayerAdded:Connect(function(plr) --player added plr.CharacterAdded:Connect(function(char) --character added wait(5) char.Archivable = true --it will return nil if the cloned object is not archivable local clone = char:Clone() clone.Parent = game.Workspace --Put it in workspace end) end)
I hope this worked!
You forgot to set archivable of player to true You need to set true "Archivable" in player model for fix it. If archivable is false, you can't clone. if archivable is true, you can clone. Remember: All characters spawn with archivable false.
What archivable makes?
Determines if an Instance can be cloned using Instance:Clone or saved to file
For your code you need to set archivable of player to true, after clone set to false.
Example:
local obj = workspace.Model Obj.Archivable = true local clone = Obj:Clone() clone.Parent = workspace Obj.Archivable = false
Fixed script:
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) wait(5) char.Archivable = true local d = char:Clone() d.Parent = game.Workspace char.Archivable = false end) end)
Hope it helped :)
Wiki pages: Archivable
If works, not forgot to accept a answer or put [SOLVED] in title.