Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I have 2 teams how can I make it that one team can't take damage??

I have 2 teams how can I make it that one team can't take damage and the other team can??

2 answers

✓ Accepted answer

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

11 comments

0

The code keeps coming up with errors

0

would u be able to tell me what the errors are?

0

Yes, it keeps saying line 1 and 3 you forgot to close

0

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

0

Ok I will test it thanks

0

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.

0

oop i know what to do, ill edit the answer

0

On line 5 Humanoid keeps getting underlined in blue with an error saying unknown global and it doesn't work

0

ill fix it

0

should work now

0

Yay it works thanks

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

0

Where should I put the script? And is it local or normal script? Also thank you for helping!!

0

Do you have a button, command, or anything that you want it to do that?

0

most likely a normal script

0

It is a regular script, you should put it inside of serverscriptservice.

0

It is a regular script, you should put it inside of serverscriptservice.

0

I don't know why it posted twice.

0

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

0

wdym? math.huge() is infinite how could it take damage?

This discussion is preserved as it was. New answers, comments, and votes are closed.