Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Camera gets stuck when player dies?

function onTouched(hit)
hit:BreakJoints()
end
connection = script.Parent.Touched:connect(onTouched)

There is a block in front of the train that breaks the joints and when it hits the player the player dies, and the camera stays at the location they died. Is it possible to force the camera to go to the player?

https://youtu.be/iCNfqj07EEU

1 answer

In a local script, listen for when the player dies, and then when he respawns. Then set the CameraType to custom and CameraSubject to the player's humanoid.

local Localplayer = game:GetService("Players").LocalPlayer
local CurrentCamera = workspace.CurrentCamera -- like localplayer, this is only accessible from local scripts

Localplayer.Character:WaitForChild("Humanoid").Died:Connect(function()
	repeat wait() until Localplayer.Character:FindFirstChild("Humanoid") -- waits for character to respawn
	CurrentCamera.CameraType = Enum.CameraType.Custom
	CurrentCamera.CameraSubject = Localplayer.Character.Humanoid
end)

This should work, do tell if it doesn't.

This discussion is preserved as it was. New answers, comments, and votes are closed.