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

Humanoid new "health" energy or stamina?

I want to create and assign a variable (Energy) to the humanoid by Script like a (Health). e.g.: Energy / Humanoid / Player

Is possible without Script, however is not displayed in "Game" in the Humanoid object. • Create a variable in StarterGui • Create a variable in StarterPack • Create a variable in StarterPlayer

It's possible? Any suggestion?

Is it possible to create a variable for the Humanoid object per instance?

humanoid = Instance.new ("Humanoid")

(I do not know how it works)

I already spent 10 hours of research and I did not find anything

2 comments

0

Dont Assign Anything to the Humanoid, Create either new bool Values or intValues within the character.

0

That's what he thought. In the Humanoid documentation there is nothing to talk about this compared to the objects and properties. Either way, how variables can improve practice. Thanks for sharing!

2 answers

You cant add a new proppertie to the Humanoid I think but you can add new Values though. Like this below! :

game.Players.PlayerAdded:Connect(function(player)

player.CharacterAdded:Connect(function(character)

local stamina = Instance.new("IntValue")--- AN IntValue is a Value that only has Whole Numbers or Integers

stamina.Parent = character---Set The Parent for the Stamina "IntValue"

stamina.Name = "Stamina"---Set the Name for it

stamina.Value = 100 --- Set the Value for it!

---And Boom! Now you have your new stamina value inside your character! :D

----Now you can refference it by saying "player.Character.Stamina" or "player.Character:WaitForChild("Stamina")"

end)

end)

5 comments

0

That does not work...

0

Why wouldn't that work? I suppose if the op wanted the property inside of the humanoid you could make stamina's parent inside of humanoid instead of character..?

0

It does work dude, roblox thinks only his way works because he has 1k points. That being said, he would still need to add more code

0

^ seems to think*

0

Thanks Tizzel40 i ll try to use this code.

A simple solution might be to just put a value inside the starterCharacter folder.

2 comments

1

i agree

0

That's it. As I mentioned, it is possible. But goal was via Script.

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