Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

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
Ad
Log in to vote
-1
Answered by
wazap 100
10 years ago

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)

Answer this question