I am making a pirate game and when I click the regen button to spawn another ship more than once I get an error like this:
The Parent property of SloopCopytwo is locked, current parent: NULL, new parent Workspace
So it does not work more than once and don't know how to fix this issue It also does not clone multiple of the same ship like I would like it too here is my script for the ship spawner.
game.ServerStorage.smallshiptwo.Archivable = true copy = game.ServerStorage.smallshiptwo:clone() game.ServerStorage.smallship.Archivable = false local detector = game.Workspace.Regensloop script.Parent.ClickDetector.MouseClick:Connect(function() copy.Parent = game.Workspace copy.Name = "SloopCopytwo" copy:MoveTo(Vector3.new(152, 2.5, -90)) end)
thanks.
Okay, so. Just like what I said in the comment, it may have been garbage-collected, garbage-collection is an automatic process of freeing up space in a computer's memory by removing data that is no longer required or in use. And I advise to actually set the model's archivable to true.
Anyway, here's my solution: (Untested)
local ServerStorage = game:GetService("ServerStorage") -- This is just personal preference, you don't have to set a variable for this. You can just use game.ServerStorage local detector = workspace.Regensloop -- Question, what's the use of this in your script? script.Parent.ClickDetector.MouseClick:Connect(function() local Copy = ServerStorage:FindFirstChild("smallshiptwo"):Clone() Copy.Name = "SloopCopytwo" Copy.Parent = workspace Copy:MoveTo(Vector3.new(152, 2.5, -90)) end)
So, what changed is that I moved the cloning into the MouseClick function. If you do it outside of the function, it would only clone once, but in this script, it clones whenever the ClickDetector is triggered.