I have 2 teams how can I make it that one team can't take damage and the other team can??
I have 2 teams how can I make it that one team can't take damage??
2 answers
modified the other answer. Put this in a Server Script. If that doesn't work, use a local script. Store the server script in ServerScriptService and if it's a local script, put it in starterGui
while wait() do
for i, v in pairs (game.Teams:WaitForChild("TEAM_NAME_HERE"):GetPlayers()) do
for j, k in pairs(v.Character:GetChildren()) do
if k:IsA("Humanoid") then
local Humanoid = k
Humanoid.Health = 100
end
end
end
end
You should use a for index value loop.
Replace TEAM_NAME_HERE with the name of the team.
Script to make one team not take damage
for i, v in pairs (game.Teams:WaitForChild("TEAM_NAME_HERE"):GetPlayers()) do
v.Character:WaitForChild("Humanoid").MaxHealth = math.huge()
v.Character:WaitForChild("Humanoid").Health = math.huge()
end
Script to make all players able to take damage again
for i, v in pairs(game:GetService("Players"):GetPlayers()) do
v.Character:WaitForChild("Humanoid").MaxHealth = 100
v.Character:WaitForChild("Humanoid").Health = 100
end
8 comments
Where should I put the script? And is it local or normal script? Also thank you for helping!!
Do you have a button, command, or anything that you want it to do that?
most likely a normal script
It is a regular script, you should put it inside of serverscriptservice.
It is a regular script, you should put it inside of serverscriptservice.
I don't know why it posted twice.
It didn't really work. All the script does is change the health to be higher I'm wanting to make sure the team can't at all take any damage
wdym? math.huge() is infinite how could it take damage?
This discussion is preserved as it was. New answers, comments, and votes are closed.

11 comments
The code keeps coming up with errors
would u be able to tell me what the errors are?
Yes, it keeps saying line 1 and 3 you forgot to close
Shoukld work now, I forgot to put an end for the if statement. I fixed it. Just copy it and try it again and it should work
Ok I will test it thanks
It still doesn't work. The player on the team that I don't want to take damage still takes damage. There are no errors tho.
oop i know what to do, ill edit the answer
On line 5 Humanoid keeps getting underlined in blue with an error saying unknown global and it doesn't work
ill fix it
should work now
Yay it works thanks