Hi I’m making a game for my online class and it is a fighting game.
I’m trying t add Anti-Team Kill (ATK) and the script will not work!
I’m also using the FE melee kit (2021) (Because I’m bad at coding)
And i need help.
This is he code for the ATK.
function onHumanoidDied(humanoid, player)
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
if (killer ~= nil) then
handleTKs(player, killer)
end
end
function onPlayerRespawn(property, player)
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)
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
local killer = tag.Value
if killer.Parent ~= nil then
return killer
end
end
return nil
end
function handleTKs(player, killer)
if (killer.TeamColor == player.TeamColor) then
killer.Character.Humanoid.Health = 0
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)
Is there a problem?
This is what it looks like in game.
Please help!
(P.S I’m new to this coding language)