I want to stop Team kill With My sword script, but I can't figure out how to alter my code to check if who I'm hitting is on the same team or not as the person who hits them because it is a different than other Anti team kill scripts, I read that revolve around Humanoid.Health then what I Used TakeDamage().
Here is the Script.
Handle.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Tool.Parent then if Debounce == true and PlayersHit[Hit.Parent] == nil then Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(math.random(15,35)) PlayersHit[Hit.Parent] = true wait(1) PlayersHit[Hit.Parent] = nil end end
end)
I just copied and pasted this code from a model I used earlier
Hope It works
Script:
Tool.Handle.Touched:Connect(function(hit) ----When a victim gets hit by axe --This Is optional but I decided to use It just Incase Its a Team vs Team (TvT) game, like brickbattle local player1 = game.Players:GetPlayerFromCharacter(hit.Parent) local player2 = game.Players:GetPlayerFromCharacter(Tool.Parent) if (player1 ~= nil) and (player2 ~= nil) then local humanoid = (player2.Character or player2.CharacterAdded:Wait()):FindFirstChildWhichIsA("Humanoid") if (player1.TeamColor ~= player2.TeamColor) then if (humanoid ~= nil) and CanDamage == true then Sounds.HeadCut:Play() humanoid:TakeDamage(math.random(250,1000)) humanoid.Parent.Head:Destroy() CanDamage = false end end end end)