Detect a player was killed by something

English is not my language so my grammar will probably wrong, but I would try my best to explain.

  1. What do you want to achieve? Keep it simple and clear!
    -The title says it all, I want to detect if a player was killed by something. I will talk more about what I am trying to do below
  2. What is the issue? Include screenshots / videos if possible!
    -I just wonder is it possible. If it is, you don’t need to script for me, you can give me some hints, advices, or maybe Youtube tutorials.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    -I played around with the values. Like, touched the obstacles will create a value, and a script will check if there is that value, you will be teleport back. But when I deeper this way, it just make me more confused and messed up.
    More information
    So basically, I made a parkour game + murder mystery. If the player died by the obstacles, or fell into dead water, they will allow to respawn, but if the player get killed by the murder, they will teleport back to the lobby. I have had success with the matchmaking system, role picker and checkpoints

Your replies would be so good for me. By the way, thanks for your help!

1 Like

Place a script in the murderer’s tool (whatever you use to kill other players) to create a StringValue in the player’s (the one who got killed) character.
(Make sure that the StringValue is placed in a child of the player that does not get destroyed on death)
Then add a Humanoid.Died function to detect when the player dies, and read from the StringValue to see who killed them.

Personally I would create the StringValue when the player spawns and set it to “nobody” as the default value, then change the value when killed by a player. Then use an if statement to check the value of the StringValue.