Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 1 year ago

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

2 answers

Log in to vote
2
Answered by 1 year ago
Edited 1 year ago

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
0
The code keeps coming up with errors blue_bunny0fficl 98 — 1y
0
would u be able to tell me what the errors are? bittyboy1234 91 — 1y
0
Yes, it keeps saying line 1 and 3 you forgot to close blue_bunny0fficl 98 — 1y
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 bittyboy1234 91 — 1y
View all comments (7 more)
0
Ok I will test it thanks blue_bunny0fficl 98 — 1y
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. blue_bunny0fficl 98 — 1y
0
oop i know what to do, ill edit the answer bittyboy1234 91 — 1y
0
On line 5 Humanoid keeps getting underlined in blue with an error saying unknown global and it doesn't work blue_bunny0fficl 98 — 1y
0
ill fix it bittyboy1234 91 — 1y
0
should work now bittyboy1234 91 — 1y
0
Yay it works thanks blue_bunny0fficl 98 — 1y
Ad
Log in to vote
2
Answered by 1 year ago

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
0
Where should I put the script? And is it local or normal script? Also thank you for helping!! blue_bunny0fficl 98 — 1y
0
Do you have a button, command, or anything that you want it to do that? T3_MasterGamer 2189 — 1y
0
most likely a normal script T3_MasterGamer 2189 — 1y
0
It is a regular script, you should put it inside of serverscriptservice. BoiBoi24T 63 — 1y
View all comments (4 more)
0
It is a regular script, you should put it inside of serverscriptservice. BoiBoi24T 63 — 1y
0
I don't know why it posted twice. BoiBoi24T 63 — 1y
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 blue_bunny0fficl 98 — 1y
0
wdym? math.huge() is infinite how could it take damage? T3_MasterGamer 2189 — 1y

Answer this question