So I used this
script.Parent.Touched:Connect(function(hit) local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(character) if player then if player.Team.Name ~= script.Team.Value then character.Humanoid.Health = character.Humanoid.Health -math.random(50,100) end end end)
And It damages the players on the other team but not NPC'S, how can I change It so NPC's can be damage as well of enemies on the other team? (NOTE: AN STRINGE VALUE IS INSIDE OF THE SCRIPT)
Should work: (Im on mobile)
script.Parent.Touched:Connect(function(hit) local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(hit) if player then if player.Team.Name ~= script.Team.Value then character.Humanoid.Health = character.Humanoid.Health -math.random(50,100) end else -- if it isnt a player then if hit.Parent:FindFirstChild("humanoid") then character.Humanoid.Health = character.Humanoid.Health -math.random(50,100) end end end end)