Anti killing certain teams as a team, need help!

Hello Robloxians!

The title might of made no sense so just to clarify what I said… I am trying to make a SCP game and I need help making a script that makes it so if you are a team, you can’t kill teams above you and your own team, I’ve been trying to make a script like this for a while now and can’t figure it out.

For example, if you were Team A, you could kill everyone because team A is class-d, team B though lets say is a intern, the Team B cant kill their own team and cant kill team C or any team above them.

I hope that made sense, if you can help then thank you! :slight_smile:


I would add some values into the teams themselves like this:


This way, you can set the team priority value and whenever player is supposed to give damage to another, just check if the victim’s priority is lower than the attacker’s.

Put some number values named “Level” in each team and then put what level you want. Then in the anti kill script, use this function:

function canUserKill(killer,victim)
	if killer.Team.Level.Value >= victim.Team.Level.Value and killer.Team ~= victim.Team then
		return true
		return false

Theres many ways to accomplish this.

The first way would be pretty manual, just check if the players team and check who they are trying to kill. Spaghetti, but it works.

The second way would be, in my opinion, an easily automated task.

local perms = 0

for i, teams in pairs (game.Teams:GetDescendants()) do
      if teams:IsA("Value") and teams > perms then
            perms = teams

this code checks for the highest ranking team based on integer values. I’d advice making these values in the teams. Too complicated? Just use the floppy way.

This script was not formated right and looks like it would not work anyway.