This happens if I my character respawns second time

local player = game:GetService("Players").LocalPlayer
local camera = workspace.CurrentCamera or workspace.Camera
local follow = true
local con
local RootPart 

player.CharacterAdded:wait()
player.Character:waitForChild'HumanoidRootPart'
local hum = player.Character:waitForChild'Humanoid'

con = hum.Died:Connect(function()
	hum = nil
	follow = false
	con:Disconnect()
	con = nil
end)
RootPart = player.Character:waitForChild'HumanoidRootPart'
camera.CameraSubject = RootPart
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 70

function refresh()
if con then
	con:Disconnect()
	con = nil 
end
follow = true

player.CharacterAdded:wait()
player.Character:waitForChild'HumanoidRootPart'
hum = player.Character:waitForChild'Humanoid'
	
con = hum.Died:Connect(function()
	hum = nil
	follow = false
	con:Disconnect()
	con = nil
end)
RootPart = player.Character:waitForChild'HumanoidRootPart'
camera.CameraSubject = RootPart
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 70
	
end
player.CharacterAdded:connect(refresh)

game:GetService("RunService").Heartbeat:Connect(function()
	if follow then
		camera.CFrame = CFrame.new(RootPart.Position) * CFrame.new(0,2,15)
	end
end)

2 comments

0

Where is the script located ?

0

StarterPlayerScripts and named "CameraScript"