Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make someone's camera follow another person's camera?

I'm attempting to make a killcam script. How do I make it so that the player's camera follows the person who killed them when they die?

2 answers

✓ Accepted answer

This is a really common script that you can find in free models. Just search for "killcam script" and you'll find several.

I'll walk you through the basics though:

  1. Detecting what player killed you: Most tools create an ObjectValue named "creator" in your character when they damage you. When your Humanoid's Died Event fires, you check if the "creator" tag exists inside your character. If it does, it gives you a reference to the player who killed you.

Example:

player.Character.Humanoid.Died:connect(function()
	local killerTag = player.Character.Humanoid:findFirstChild("creator")
	if killerTag then
		local killerPlayer = killerTag.Value
	end
end)
  1. Making your camera follow another person's character

Just set your camera's CameraSubject property to the other player's character.

Example:

local camera = game.Workspace.CurrentCamera -- must call from a localscript
camera.CameraSubject = killerPlayer.Character

local hum =game.Players.LocalPlayer.Character.Humanoid hum.Died:connect(function() if hum:findFirstChild"creator" then workspace.CurrentCamera.CameraSubject = hum.creator.Value.Character.Humanoid end end)

This discussion is preserved as it was. New answers, comments, and votes are closed.