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)