Camera stays put when you die

I have used a youtube tutorial to make a camera part where it focuses on a certain place. Though when you die and press play you can walk but you can only see the place where you died.
Here is the tutorial: How to make a Piggy Game (Part 1): Main Menu | Roblox Studio!! - YouTube

and here is the game if you want to see the glitch for yourself:

Any help on how to fix this is appreciated.

Save the camera CFrame/position after the player dies, then after the player respawns, set the Cameratype to ā€˜Scriptableā€™ and set the Camera CFrame to the saved one.
Would look like:

local pos = Camera.Position

after respawn:

game.Workspace.CurrentCamera.CameraType = Enum.CameraType(ā€œScriptableā€)
game.Workspace.CurrentCamera.Position = pos

Do i make a new script for this or do i put it with the already existing main menu one?

probably a new script but you could do main menu (itā€™d be a bit weirder to make I think)

Where should i put that script? And should it be local or the normal type? sorry for all this I am new to scripting.

Itā€™s fine, Iā€™ve been there before lol.
Local script since server script canā€™t access client camera stuff.

ok and where do i put in the starter player scripts im guessing?

Idk, I know StarterGui will work, not sure what else.

ok thanks i will try it right now

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()

char.Humanoid.Died:Connect(function()
--camera stuff here
end) 

In Local pos = Camera.Position.
Camera is underlined in red.
and in game.Workspace.CurrentCamera.CameraType = Enum.CameraType(ā€œScriptableā€)
Scriptable is also underlined in red. How do i fix that?

1 Like

Oh yeah, it was a demo script. Iā€™m not 100% sure since Iā€™m on a phone.
local should be lowercase, there shouldnā€™t be a period at the end.
So

local pos = Camera.Position --path camera

Oh no problem thats fine i will try to fiddle with the script you sent to find my answer

1 Like

I just had to fiddle a bit and create another variable and it worked heres what i used.
local camera = workspace.CurrentCamera

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:wait()

char.Humanoid.Died:Connect(function()

local pos = camera.Position --path camera

game.Workspace.CurrentCamera.CameraType = Enum.CameraType(ā€œscriptableā€)

game.Workspace.CurrentCamera.Position = pos

end)

1 Like

the only problem is that this script causes an error in the output

I did not check the output yet what does it say?

it says something about position is not a valid member of camera workspace.camera

Do you know a way to fix it? Because I am very new to scripting so I do not know much.

try this updated version I made:

local camera = workspace.CurrentCamera

local plr = game.Players.LocalPlayer

local char = script.Parent

char.Humanoid.Died:Connect(function()

	local pos = camera.CFrame --camera CFrame
	
	camera.CameraType = Enum.CameraType.Scriptable

	camera.CFrame = pos
	
	task.wait(game.Players.RespawnTime) --wait
	
	camera.CameraType = Enum.CameraType.Custom
end)

if not script.Parent:IsA("Model") then
	warn('place in startercharacterscripts')
end

Thank you I will try right now.