CurrentCamera Glitch on Death

Hi. Glad to see you here. I made this script that when the player died, it would call a RemoteEvent.

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild('Humanoid').Died:connect(function()
			game.ReplicatedStorage.DeathFunc:FireClient(player)
		end)
	end)
end)

Then the LocalScript picks up the RemoteEvent and starts to function.

game.ReplicatedStorage.DeathFunc.OnClientEvent:Connect(function()
	repeat wait()
		cam.CameraType = Enum.CameraType.Custom
	until cam.CameraType == Enum.CameraType.Custom
end)

There are no errors. The function is in ReplicatedStorage. If you have any questions message below and if I forgot something message me!

1 Like

what is the issue? 30 character

2 Likes

You say “function” is DeathFunc a RemoteFunction or RemoteEvent?

Because there are different ways to fire these events, along with different ways to connect to the event.

1 Like

When the player is viewing a camera then resets, the camera just ‘floats’ in the air. I might show a video.

1 Like

I mean the ‘function’ as a RemoteEvent. Sorry for saying it wrong above

Functions have OnServerInvoke/OnClientInvoke and use InvokeServer/InvokeClient.

You might want to change what you said you’d call a RemoteFunction to RemoteEvent.

See the message right above yours, he just corrected himself and stated that he said the wrong remote type above.

So, you’re setting the camera type, back to Custom, but are you setting the Camera Subject back to the Humanoid?

1 Like

robloxapp-20200327-1745524.wmv (2.4 MB)

I didn’t say anything about the camera subject.

Setting the CameraSubject back to the player’s Humanoid should fix the problem.

1 Like

But how should I write it? I never used CameraSubject before.

game.ReplicatedStorage.DeathFunc.OnClientEvent:Connect(function()
	repeat wait()
		cam.CameraType = Enum.CameraType.Custom
	until cam.CameraType == Enum.CameraType.Custom
    local character = player.Character or player.CharacterAdded:Wait() --Assuming that player is your LocalPlayer variable name
    cam.CameraSubject = character:WaitForChild("Humanoid")
end)
2 Likes