I have a local script checking for the player’s HumanoidRootPart and Character so it can set the spawn based on a certain value but this just pops up?
My script:
local plr = game.Players.LocalPlayer
local char = plr.Character
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
--first time playing?
if plr:WaitForChild('PlayerStats').SavePoint.Value == 0 then
char.HumanoidRootPart.CFrame = workspace.StartSpawn.CFrame
end
repeat wait() until game.Players.LocalPlayer -- Wait until the player is loaded
local plr = game.Players.LocalPlayer
local char = plr.Character
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
--first time playing?
if plr:WaitForChild('PlayerStats').SavePoint.Value == 0 then
char.HumanoidRootPart.CFrame = workspace.StartSpawn.CFrame
end
Only core scripts have to worry about the LocalPlayer being loaded. You don’t need to wait for LocalPlayer to exist. The problem is that the character wasn’t spawned in yet. The reason the error stopped with this solution is because of the wait() in the repeat loop. It runs before it checks the condition in the loop, so this is a band-aid fix, which will only work on fast computers. He should use this instead:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()