I have a vehicle that uses a 3rd person camera that is a part in the vehicle model that I set the CurrentCamera CFrame to. When the player dies, I make the vehicle model explode and then destroy itself. I have the player spawn as the vehicle and they are not meant to exit it. When the player respawns and gets put into the vehicle, the camera CFrame rapidly glitches between the position of the old camera part and the new one.

I have tried to set the CFrame to (0, 0, 0) directly after death and even change the name of the ship to "Dead ship" in the workspace but it still does it.

Here is what i have tried:

local char = game.Workspace:WaitForChild(plr.Name)

char:WaitForChild("Humanoid").Died:Connect(function()
			
	camera.CFrame = CFrame.new(0, 0, 0)
	
	wait(8) -- wait for the player to respawn and a new ship to appear

	local ship = game.Workspace:FindFirstChild(plr.ship.Value)
	
	camera.CameraSubject = ship.Center
	camera.CameraType = Enum.CameraType.Scriptable
	
	camera.CFrame = ship.CamPart.CFrame
	
	camera.Focus = ship.Center.CFrame
end)

3 comments

0

use plr.Character to get the player's character

0

Are you spawning a camera controller for each player respawn that's not getting cleaned up on death? Where are your camera.CFrame and camera.Focus being set from when the character is alive?

0

This is only the block that occurs on death. I defined the CFrame and focus earlier in the script.