Hello,
EDIT: Original anti-TK script was sorted out, reposting the now correct script with the new weird issue.
I have a sword script, thanks to user ScrewDeath, I was able to fix the error. But now, I can not inflict damage on NPCs who all have the "Humanoid" property. Do I need to set them to a team?
Error is: 00:42:31.079 - Players.Player1.Backpack.BasicSword.SwordScript:6: attempt to index local 'TargetPlayer' (a nil value)
Damage section of the Sword Script:
handle.Touched:connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local TargetPlayer = game.Players:GetPlayerFromCharacter(humanoid.Parent) if equipped and character and humanoid and humanoid.Health > 0 and hit and not hit:isDescendantOf(character) then if humanoid and humanoid.Health > 0 and not hithumanoids[humanoid] and (TargetPlayer.TeamColor ~= player.TeamColor or not TargetPlayer) then hithumanoids[ humanoid] = true for _, v in pairs( humanoid:GetChildren()) do if v and v.Name == "creator" then v:remove() end end local tag = Instance.new("ObjectValue") tag.Name = "creator" tag.Value = player debris:AddItem(tag, 3) tag.Parent = humanoid humanoid:TakeDamage(damage * (combo + 1)) else end end end end)
First thing you should look at when rubber ducking is look and comprehend the actual error you are being given: "TeamColor is not a of Humanoid". I'm just going to assume you left out 'member' or something off that error.
So, TeamColor is apparently not a valid property of Humanoid. Bam. There's your problem. You're tryna read something that don't exist. What you would probably want to do is use the humanoid's parent (or the character model) 's name and game.Players:GetPlayer(model.Name) that. That'll give you the player object which is the thing you're looking for.
PS: You say it's FilteringEnabled but I don't see a call to a remoteFunction/Event anywhere. Haven't really tinkered w/ that stuff much so I might be wrong...