The Parent property of Rafts is locked, current parent: NULL, new parent Workspace

the map appears and later disappears only once. Then an error appears. Please help me fix it!

local intermission = 5
local roundlength = 10
local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status
local maps = game.ReplicatedStorage.Maps:GetChildren()
local chosenmap = maps[math.random(1, #maps)]
local clonemap = chosenmap:Clone()
inround.Changed:Connect(function()
if inround.Value == true then
for i, v in pairs(game.Players:GetPlayers()) do
local character = v.Character
local humanoidrootpart = character:WaitForChild(“HumanoidRootPart”)
clonemap.Parent = game.Workspace
humanoidrootpart.CFrame = clonemap.Teleport1.CFrame
humanoidrootpart.CFrame = clonemap.Teleport2.CFrame
end
else
for i, v in pairs(game.Players:GetPlayers()) do
local character = v.Character
local humanoidrootpart = character:WaitForChild(“HumanoidRootPart”)
local lobby = game.Workspace.Spawn
humanoidrootpart.CFrame = lobby.Tp1.CFrame
humanoidrootpart.CFrame = lobby.Tp2.CFrame
end
clonemap:Destroy()
end

end)
local function round()
while true do
inround.Value = false
for i = intermission, 0 , -1 do
status.Value = “Intermission:”…i
wait(1)
end
inround.Value = true
for i = roundlength, 0, -1 do
status.Value = “Liquidation:”…i
wait(1)
end
end
end
spawn(round)

1 Like

1 Like

Could you either format it or send a screenshot of the script because currently line 13 for this script is

local humanoidrootpart = character:WaitForChild(“HumanoidRootPart”)
1 Like

You destroy clonemap, so you can’t reparent it.

thank you. how can I fix this error?

Don’t destroy clonemap? Unless you need a new map each time, in which case clonemap should be cloned each time you need it.

1 Like

it doesn’t work. the error remains the same

put
clonemap = chosenmap:Clone()
at the start of the
inround.Changed:Connect(function() event

or

instead of :Destroy() use :Remove() to not lock the parent

thank you very much for your help. However, another problem has appeared. Teleport1 is not a valid member of Model “Workspace.Desert”


as you can see, the Teleport1 object is located in the Desert folder. could you please help me with solving this problem

Check the Anchored and CanCollide properties of the teleport parts.
If its collisions are off and its unanchored it will fall trough the ground.

it doesn’t work :frowning: perhaps it is worth changing the name of these objects?

Check if they are in the map in Workspace when you playtest. If they are maybe you just need to wait for them with :WaitForChild()

the problem was half solved. on the one hand, the problem has stopped being displayed. But now I don’t get into the playing field at all. I’ll send the video. I don’t know if it will help you

Teleport1 is not a part of the map.

did you do this?
Not in Replicated Storage, but in Workspace

One thing I can think of is the part falling into the void because it has CanCollide set to false and Anchored set to true.
Other possibility is that it is getting destroyed by another script.

the map appears in Workspace only without internal folders

Sorry, I made a mistake. :Remove() removes all the descendants of the part as well.

local intermission = 5
local roundlength = 10
local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status
local maps = game.ReplicatedStorage.Maps:GetChildren()
local chosenmap = maps[math.random(1, #maps)]
local clonemap
inround.Changed:Connect(function()
if inround.Value == true then
clonemap = chosenmap:Clone()
for i, v in pairs(game.Players:GetPlayers()) do
local character = v.Character
local humanoidrootpart = character:WaitForChild(“HumanoidRootPart”)
clonemap.Parent = game.Workspace
humanoidrootpart.CFrame = clonemap.Teleport1.CFrame
humanoidrootpart.CFrame = clonemap.Teleport2.CFrame
end
else
for i, v in pairs(game.Players:GetPlayers()) do
local character = v.Character
local humanoidrootpart = character:WaitForChild(“HumanoidRootPart”)
local lobby = game.Workspace.Spawn
humanoidrootpart.CFrame = lobby.Tp1.CFrame
humanoidrootpart.CFrame = lobby.Tp2.CFrame
end
clonemap:Destroy()
end

end)
local function round()
while true do
inround.Value = false
for i = intermission, 0 , -1 do
status.Value = “Intermission:”…i
wait(1)
end
inround.Value = true
for i = roundlength, 0, -1 do
status.Value = “Liquidation:”…i
wait(1)
end
end
end
spawn(round)

Could you try this?

thank you very much. everything works fine except that I now have only one map out of two. either I was unlucky that I had only the “Rafts” map out of 10 rounds, or something was wrong in the script

Try to figure that out yourself or open a new topic.
Glad to help with this one!

1 Like