This may sound strange and confusing, but when I was working on an FPS game, my lead developer stumbled upon a mystery bug and reported it to me. He described:
-
Here, you are on the menu screen when your character spawned. (The real character is outside of this scene)
-
You click “DEPLOY” button.
-
You end up on Roblox’s default spawn location instead of the desired point. (VV that’s the lead dev on picture VV)
Me and my lead dev believed that there was a faulty in the core game code. So we checked it. However, after examination, there was no flaw in the code, especially the deployment part. But how come?
The server code uses RemoteFunction to be given time to be ready when the client requests.
- Initially, the code checks if the character exists. After that, the player is given the equipment they chose from loadout.
if not Player.Playing.Value then
Player.Playing.Value = true
local Character = Player.Character or Player.CharacterAdded:Wait()
if Character == nil then
Player.Playing.Value = false
return false
end
--[the code below gives player equipments or something...]
end
- When equipment is loaded into the player, the code begins teleporting the character to the desired location. But before that, it must teleport the player to the red room, just in case of they have any problems. The code should be like this:
--[...]
local SpawnObj = workspace.TempLobby.Default
local SpawnName = "BUGGED"
local PosStr = Vector3.new(0, 0, 0)
local SpawnCFrame = SpawnObj.CFrame
local Succeed = false
Character:PivotTo(workspace.TempLobby.Default.CFrame + Vector3.new(0, 5, 0))
--[VVVproximity spawn check or something...VVV]
- After some proximity spawn check, the code returns true and the player is ready to be deployed.
print(Player.Name.." spawned on "..SpawnName..". Spawn parent: "..SpawnObj.Parent.Name..". Position: X_"..PosStr.X..", Y_"..PosStr.Y..", Z_"..PosStr.Z)
Character:PivotTo(SpawnCFrame + Vector3.new(0, 5, 0))
task.delay(0.1, function()
if not Player then return end
Player:SetAttribute("__NC_Ignore", nil)
Player:SetAttribute("__SP_Ignore", nil)
end)
for _, v in pairs(script.CharacterScripts:GetChildren()) do
local NewScript = v:Clone()
NewScript.Parent = Character
NewScript.Disabled = false
end
if not NoFallDamage.Value then
local NewScript = script.FallDamage:Clone()
NewScript.Parent = Character
NewScript.Disabled = false
end
if DisableSwim.Value then
local NewScript = script.DisableSwim:Clone()
NewScript.Parent = Character
NewScript.Disabled = false
end
Player.Deployed.Value = true
print(Succeed and "Successfully deployed" or "Failed to deploy due to possible glitch")
return true
Despite everything, the character still remains on the default spawn location (not red room), even the logs showed the correct locations (note that the Roblox default location name is just “SpawnLocation”)
It’s been a few months and we are still struggling to find the root of the cause. If you have any answers, don’t hesitate to reply to this thread. Also, here’s the clues:
- This happens occasionally.
- The code uses PivotTo() to optimize teleporting.
- Player characters always get parented to “Characters” folder when spawning