My friend created a “Bossfight” for his game and, there is a part where the camera will be in and, so yeah; when the player dies, it remains in the part’s position and, we want the camera to go back to the player.
Here’s the script when you enter the arena:
local Cam = game.Workspace.CameraPart
local Act = game.Workspace.Act
local debounce = false
Act.Touched:Connect(function()
if debounce == false then
debounce = true
if workspace.CurrentCamera.CameraType == Enum.CameraType.Scriptable then
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
wait(1)
debounce = false
else
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = Cam.CFrame
wait(1)
debounce = false
end
end
end)
Trying your script in a test place of mine (considering it was a LocalScript), I have found a solution.
You should probably just have a LocalScript in StarterCharacterScripts that just sets the CameraType to Custom on execution. Since that script should only run when the character has loaded, this is perfect for when the player respawns to reset any camera manipulation. Here is an example below that should work:
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local cameraObject = workspace.CurrentCamera
cameraObject.CameraType = Enum.CameraType.Custom
cameraObject.CameraSubject = humanoid
I also set the CameraSubject back to the humanoid because that I assume the camera kinda breaks when you set the CameraType directly on spawn and it keeps the old Humanoid subject.
Make sure to mark this post as a solution if this works for you!