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

How do I make a player's health increase from default (100) to 300 when they join a team?

Hey, I'm making a game and there are three teams, Gods, Mortals, and Mortal Heroes. I want the Mortal Heroes and Mortals to still have the usual 100 health but I want the player on the Gods team to have 300 health ONCE HE JOINS THE TEAM. This is in caps because it can't make him reset, it has to give him the health without him resetting. The health needs to be given to him right when he switches onto the Gods team (which he does by stepping on a spawn point) without him having to reset or die in any way. This was my attempt at it, it is fairly simple but I can tell it didn't work, what should I change about it to make it work?

if player.TeamColor == "Lapis" then
player.Health = 300
end

Note: The team color for Gods is Lapis. The color for Mortals is New Yeller. And the color for Mortal Heroes is Really Red, just in case you need any of that information. Thanks, Skyraider5

1 answer

Alright, here we are again.

The problem in your script is easy to understand, but it's very hard to solve, not even saying that it might be impossible

The problem is: Humanoids can't have an health that's bigger than 100... If..... MaxHealth remains on 100.

You also have to change the MaxHealth IntValue. You also forgot to write the .Character.Humanoid path. Here, try this.

game.Players.PlayerAdded:connect(function(player)
--Because the team could not change right in the Player Adding, let's add a loop!
    while wait() do
        if player.Team == game.Teams.Gods then --Yeah... TeamColor is screwed T_T
            player.Character.Humanoid.MaxHealth = 300
            player.Character.Humanoid.Health = 300
        end
    end
end)

If it works, please mark this answer as the Solution.

As always, good scripting! ;)

11 comments

0

Yeah I just updated this, so just to check, if you're seeing this for the first time, refresh the page.

0

It didn't work, is there anything else i would have to add anywhere to make the script work? Also, where should I put the script?

0

I'd change line 4 to: if player.Team == "Lapis" then

0

@Skyraider5 it's strange it didn't work, but listen, you gotta use a LOCALSCRIPT in the Workspace. If it won't work still, then remove the loop (remove the while wait() do and the second end couting from down)

0

Ok, I put it in a local script in the workspace but is there anything else I would need to add for it to work, like a humanoid or an IntValue or something? Or would the script alone do it?

0

You don't need to do anything. The local script is working.

0

ok so if I just put the local script in the workspace and do nothing else it should work?

0

Yes

0

Hey OtcPedroo, Thanks for the help but whenever I test it, the God player still has only 100 health. If I go on test mode and then look on the explorer at the model that is my player, I can go to the humanoid inside that model and change it that way but the script doesn't change anyone's health. Any other ideas?

0

Ok... god is the team name. but what's that team's color? Are you sure its lapis?

0

ALRIGHT IK! I just edited the script, it will work now @Skyraider5!!! #Tested

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