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

How do I script it so the max health is always = to a leaderstat?

Asked by 4 years ago

What evert he leaderstats is or if it even changes I want the maxhealth of a player to equal to it. Ive tried many things but I can't seem to change the max health being always = to a leaderstat. My leaderstat script is fine.

0
Please provide your code so we can better understand you. If you don't have any code, then your question might be moderated Cynical_Innovation 595 — 4y

2 answers

Log in to vote
2
Answered by
Avoxea 48
4 years ago
Edited 4 years ago
local yourplayer = --fill this in
local yourleaderstat = --fill this in
local stat = game.Players[yourplayer].leaderstats[yourleaderstat]

stat:GetPropertyChangedSignal("Value"):Connect(function(val)
     yourplayer.Character.Humanoid.MaxHealth = stat.Value
    yourplayer.Character.Humanoid.Health = stat.Value
end)

It is difficult to provide a script for you since we have no reference as to what your system is doing, but this may help you.

0
I will check it out. THUNDER_WOW 203 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You could use :GetPropertyChangedSignal on your LeaderStatValue to determine when it the Value has changed like so:

LeaderStatMaxHealth:GetPropertyChangedSignal("Value"):Connect(function()
    print("Value has changed")
end)

Edit: Since I'm unsure on how comfortable with this you might be I'll link you to an article. https://developer.roblox.com/en-us/api-reference/function/Instance/GetPropertyChangedSignal

0
I have tried that, lets say the stat was 200 even with that function the players max health would stay at 100 no matter what. THUNDER_WOW 203 — 4y
0
It sounds like your doing something wrong then. It would be much easier to help you out if you provided a script. PURGATORYAGENT_1 43 — 4y
0
I know that I am not doing something wrong. THUNDER_WOW 203 — 4y

Answer this question