Players do not spawn at SpawnLocations reparented to the workspace

Also posted here: Players do not spawn at SpawnLocations reparented to the workspace · Issue #515 · Anaminus/roblox-bug-tracker · GitHub

If a SpawnLocation is added to the DataModel, but not initially parented to the Workspace (or its descendants), then players will not spawn there. It will have to be removed from the DataModel and then moved directly to the Workspace to be considered valid.

local spawn = Instance.new("SpawnLocation")
spawn.Anchored = true
spawn.Parent = game:GetService("ServerStorage")
spawn.Parent = workspace
-- players will not spawn here
spawn.Parent = nil
spawn.Parent = workspace
-- now players will spawn here

This is an annoying bug because SpawnLocations loaded via InsertService are initially parented to a Model in InsertService, so if they are reparented to the workspace, players will not spawn at them:

local model = game:GetService("InsertService"):LoadAsset(id)
print(model.Parent)
--> InsertService
model.SpawnLocation.Parent = workspace
-- players will never spawn on this spawn

My guess is the code for registering spawns looks something like this:

game.DescendantAdded:connect(function(instance)
  if instance:IsA("SpawnLocation") and instance:IsDescendantOf(workspace) then
    table.insert(spawns, instance)
  end
end)

game.DescendantRemoving:connect(function(instance)
  if instance:IsA("SpawnLocation") then
    table.remove(spawns, instance)
  end
end)
1 Like

Months ago I came across a bug where spawn locations in Lighting affected people’s spawns. I’ll test this again in a few hours to see if your guess / theory about the spawn code needs adjusting. Unless that bug was patched and someone can save me the time d:

That bug appears to be have been fixed, at the expense of introducing this one.

1 Like