print("TK script loaded.")
function onHumanoidDied(humanoid, player)
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
if (killer ~= nil) then
handleTKs(player, killer)
end
end
function onPlayerRespawn(property, player)
-- need to connect to new humanoid
if property == "Character" and player.Character ~= nil then
local humanoid = player.Character.Humanoid
local p = player
local h = humanoid
humanoid.Died:connect(function() onHumanoidDied(h, p) end )
end
end
function getKillerOfHumanoidIfStillInGame(humanoid)
-- check for kill tag on humanoid - may be more than one - todo: deal with this
local tag = humanoid:findFirstChild("creator")
-- find player with name on tag
if tag ~= nil then
local killer = tag.Value
if killer.Parent ~= nil then -- killer still in game
return killer
end
end
return nil
end
function handleTKs(player, killer)
if killer.TeamColor == player.TeamColor then
killer.Character.Humanoid.Health = 0
else if killer.Team.Name == "| | SWAT | |" and player.Team.Name == "Security" then do
killer.Character.Humanoid.Health = 0
end
else if killer.Team.Name == "Security" and player.Team.Name == "| | SWAT | |" then do
killer.Character.Humanoid.Health = 0
end
else if killer.Team.Name == "Robbers" and player.Team.Name == "| | MAFIA | |" then do
killer.Character.Humanoid.Health = 0
end
else if killer.Team.Name == "Robbers" and player.Team.Name == "| | MAFIA | |" then do
killer.Character.Humanoid.Health = 0
end
end
end
end
end
end
end
function onPlayerEntered(newPlayer)
while true do
if newPlayer.Character ~= nil then break end
wait(3)
end
local humanoid = newPlayer.Character.Humanoid
humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )
newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
end
game.Players.ChildAdded:connect(onPlayerEntered)
COMMUNITY QUESTION
Why isnt this script killing the player that kills someone on a certain team?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Focus on line 37
it's "elseif" not "else if"
^ thanks bro fixed that but script still dont work