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.
How do I script it so the max health is always = to a leaderstat?
2 answers
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.
1 comment
I will check it out.
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
3 comments
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.
It sounds like your doing something wrong then. It would be much easier to help you out if you provided a script.
I know that I am not doing something wrong.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Please provide your code so we can better understand you. If you don't have any code, then your question might be moderated