It’s supposed to set the players camerasubject to the head after death.
It works perfectly fine in the studio but whenever I try to play test the game on the website it doesn’t work.
I assume it’s probably because the character loads before the player (I also have a startercharacter so that may be breaking something too). It doesn’t print anything since it just doesn’t fire. Does anyone know how to fix this?
local players = game:GetService("Players")
local player = players.LocalPlayer
local initChar = player.Character or player.CharacterAdded:Wait()
local function characterAdded(char)
local function died()
workspace.CurrentCamera.CameraSubject = char:WaitForChild("Head")
end
print(char.Name)
char:WaitForChild("Humanoid").Died:Once(died)
end
task.defer(characterAdded, initChar)
player.CharacterAdded:Connect(characterAdded)
Found the solution. putting a localscript and checking whether the character has been loaded in it is unreliable. Just move the script to replicatedfirst and it will load before the character
Well, localscripts do run inside the character.
Serverscripts, in fact, also run inside the character.
However, serverscripts only run when Workspace.RejectCharacterDeletions is set to Enabled.