I have 2 teams how can I make it that one team can't take damage and the other team can??
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