Sometimes when the player dies or resets, the camera stays where they died. It’s worth noting that I haven’t had this issue in any previous builds of my project (going back a year or two). This issue popped up recently when I came back to the project. I haven’t touched camera settings since I came back so it’s really weird.
So far I’ve tried adding multiple pieces to scripts to return the camera to the humanoid but nothing has worked (hence this post):
Localplayer.Character:WaitForChild("Humanoid").Died:Connect(function()
repeat wait() until Localplayer.Character:FindFirstChild("Humanoid")
CurrentCamera.CameraType = Enum.CameraType.Custom
CurrentCamera.CameraSubject = Localplayer.Character.Humanoid
end)
and
game.Players.LocalPlayer.CharacterAdded:Connect(function()
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)
(These are located in StarterGUI)
Any help is greatly appreciated!
2 Likes
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function() print("died!")
repeat wait() until game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end)
1 Like
well, this code surprisingly work whithout using playerAdded and characterAdded event
1 Like
Have you tried putting this inside a ScreenGui?
1 Like
It technically is
the whole hierarchy is StarterGUI → ScreenGUI → Menu (Frame) → this script
1 Like
oh i just realized that when player die, all localScripts inside starterGui will reset or run again, except when resetOnSpawn property on ScreenGui equal to false
1 Like
resetonspawn is set to true for my screrengui so I don’t think that’s the issue
1 Like
Well, it work fine for me, using the latest code that i posted
1 Like
I tried putting that code in the starterGUI, screenGUI, and in a frame in the screenGUI and it still won’t work for some reason x_x
1 Like
Any error in output ?
sorry if that won’t work.
1 Like
I’ve looked around some more. I’ve put multiple scripts/localscripts all over the starterGUI
I’ve put a localscript in the startercharacterscripts and tried to reset on character death, delayed after death, when certain menus are no longer visible (propertychangedsignal/attributechangedsignal)
The only thing I’ve got working as a temporary solution is I can press P to re-center the camera on the humanoid manually. but no matter what I do, it refuses to do it automatically. I’m completely stuck and feel like I’ve exhausted all my options
1 Like
I think there is a bug where the roblox camera controller script tries setting the players camera first so try this:
Localplayer.Character:WaitForChild("Humanoid").Died:Connect(function()
repeat wait() until Localplayer.Character:FindFirstChild("Humanoid")
CurrentCamera.CameraType = Enum.CameraType.Custom
CurrentCamera.CameraSubject = Localplayer.Character.Humanoid
CurrentCamera:GetPropertyChangedSignal("CameraSubject"):Wait()
CurrentCamera.CameraSubject = Localplayer.Character.Humanoid
end)
1 Like
Sorry for the bump, but I have a question. Does Humanoid.Died
run on LocalScripts as well?
1 Like
Pretty sure it does yeah.
(Extra Characters)
1 Like