Change camera on respawn

i trying to make script that attaches player’s camera to head and when player respawns camera returning back to player’s humanoid, but when player respawn camera stays in the same place where’s player died

cam = workspace.CurrentCamera;
pal = game.Players.LocalPlayer.Character;
deb = false;
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local l__RenderStepped__1 = game:GetService("RunService").RenderStepped;

function dead(inputObject, gameProcessedEvent)
	if pal.Humanoid.Health == 0 then
		deb = not deb;
		if deb == true then
			cam.CameraType = "Scriptable";


			while true do
				cam.CoordinateFrame = pal.Head.CFrame * CFrame.new(0, 0, -0.6);
				cam.FieldOfView = 86
				UserInputService.MouseIconEnabled = false
				l__RenderStepped__1:wait();
				if deb == false then
					UserInputService.MouseIconEnabled = true
					break;

				end;		
			end;
			cam.CameraType = "Custom";


		end;
	end
end;
pal.Humanoid.Changed:connect(function()
	if pal.Humanoid.Sit == true then
		deb = true;
	end;
end);

game:GetService("UserInputService").InputBegan:connect(dead)

Maybe make the CFrame of the camera as the local player’s head before changing the camera type back to custom?

1 Like

This solution is working, thank you very much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.