function HIT_HANDLE(hit, dmg, tags) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(75) PlaySound("Hit") PlaySound("Dead") end end
So basically this is the original part of the script where if the tool (the throwing knife is the tool) hits a player, it deals 75 damage, what I have been trying to do is set up the script so that if the player the throwing knife hits is a teammate, it wont do damage, and only would if it wasn't a teammate, this was my best attempt at it and still was having troubles... :/ :
function HIT_HANDLE(hit, dmg, tags) if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.TeamColor ~= Player.TeamColor then hit.Parent.Humanoid:TakeDamage(75) PlaySound("Hit") end end end
Thanks in advance to anyone who helps me figure this out!
Like cabbler said, you can't change the Player's TeamColor by just getting the Character. So then we use this function called ":GetPlayerFromCharacter()".
function HIT_HANDLE(hit, dmg, tags) local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- hit.Parent is the character but we use his function to get the player's character. if hit.Parent:FindFirstChild("Humanoid") and player then -- we will just check if it is a player too. if player.TeamColor ~= Player.TeamColor then --Not sure what the "Player" is, I left that how it is. hit.Parent.Humanoid:TakeDamage(75) PlaySound("Hit") end end end