Making a script that detects if somebody has killed the wrong player

In my game there are 3 roles, a person with a gun, a person with a knife and the rest are just survivors. I would like to make it so whenever the person with a gun shoots the wrong person (a survivor), I would like the survivor and the person with the gun to die as the person with the gun is meant to kill the person with the knife and not the survivor. How would go upon doing that? Would I have to make a creator value in the gun and insert it into the player? Or would I have to insert creator values for each player depending on their role? Or would I have to do something completely different? I have looked up what creator values are, although I am not sure what to do from here.

1 Like

So it’s Murder Mystery? Lol

When assigning the “killer”, assign a variable to the player and when someone has died check if the person that died is the same as said variable.

1 Like

Basically yes haha,

For the variable that I would have to assign to the player, do I just do it in the script entirely or make a string value and then assign it to the killer?

You can check if the player has a boolvalue that says “Murderer” or whatever it might be. You can check by using :GetPlayerFromCharacter(Character) and then check for the bool.

Thank you. I get what to do now. But how would you detect if the innocent has been killed by a gun and not anything else?

You can check if the Player has a stringvalue inside them that says “murderer.” If it doesn’t, you can get both of their characters and kill them.