How do I get my camera to stop reseting?

I need help to stop making my camera reset when I change models.

Here is the video:

Here are the scripts:

LocalScript:

local uis = game.UserInputService

uis.InputBegan:Connect(function(i,g)
	if g then
		return
	end
	if i.KeyCode == Enum.KeyCode.G then
		if script.Parent.DamageDealt.Value >= 1 then
		script.Parent.HumanoidRootPart.Anchored = true
		script.Parent.Humanoid:LoadAnimation(script.Animation):Play()
		script.RemoteEvent:FireServer()
		wait(3)
		game.ReplicatedStorage.CharChange:FireServer(game.ReplicatedStorage.Char.HollowVessel,workspace.CurrentCamera)
		else
			print("Need "..2000 - script.Parent.DamageDealt.Value.." more damage to UNLEASH.")
		end
	end
end)

ServerScript:

game.ReplicatedStorage.CharChange.OnServerEvent:Connect(function(player,model,cam)
	local char = model:Clone()
	local savename = player.Name
	local pos = player.Character.HumanoidRootPart.CFrame
	char.Name = savename
	player.Character:Destroy()
	player.Character = char
	char.Parent = workspace
	char.HumanoidRootPart.CFrame = pos
	model.GuIs.GUI:Clone().Parent = player.PlayerGui
	workspace.Camera.CFrame = cam.CFrame
end)

Pls help

1 Like

I’m still a little unclear on what you’re trying to achieve.

What’s happening here? What’s the expected outcome?

Here’s what I came up with!

-- avocado (@avodey) -w-

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer

local lastCharacter = player.Character
player.CharacterAdded:Connect(function(character)
	local camera = workspace.CurrentCamera
		
	if lastCharacter and camera then
		local cframe = camera.CFrame
		
		RunService.RenderStepped:Once(function()
			camera.CFrame = cframe
		end)
	end	
	
	lastCharacter = character
end)

When the character respawns, the camera will reset. This script saves the state of the camera just before it resets, and then reapplies the state on the next frame. So, like nothing ever happened!

Let me know if you have any questions!