generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Can leaderstats be linked to a players health/maxhealth?

Previous Thread :: Next Thread 
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
21 Feb 2015 05:00 PM
I have two parts of a script that are supposed to be linked with the players health but I just have no idea how I would write that. The way I put in my leaderstats is

local ls = Instance.new("IntValue",player)
ls.Name = "leaderstats"

and then comes 1 of my 2 problems. One of my stats, "Stamina", is supposed to decrease by another stat's value, "Weight" when your health is bellow your max health

local Stamina = Instance.new("IntValue",ls)
Stamina.Value = 100
Stamina.Name = "Stamina"

and the other simply titled as HP, determines your max HP and is changed when you have on different armors which I will script later.

local HP = Instance.new("IntValue",ls)
HP.Value = 100
HP.Name = "HP"

How would I link both of these stats to a players humanoid health and maxhealth?
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
21 Feb 2015 05:03 PM
local ls = Instance.new("IntValue",player)
ls.Name = "leaderstats"

local Stamina = Instance.new("IntValue",ls)
Stamina.Value = 100
Stamina.Name = "Stamina"

local HP = Instance.new("IntValue",ls)
HP.Value = 100
HP.Name = "HP"

local Human = game.Workspace:WaitForChild(player.Name):FindFirstChild("Humanoid").Changed

Human.Changed:connect(function()
HP.Value = Human.Health
end)
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
21 Feb 2015 06:58 PM
I'm confused, nothing about that mentioned the maxhealth property of humanoid in that. I am starting to get how it should work, but what about the first problem of stamina being related to the health property not being the same as maxhealth?
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 08:41 AM
Bump
Report Abuse
computerchris is not online. computerchris
Joined: 02 May 2009
Total Posts: 665
22 Feb 2015 10:44 AM
Which values do you want connected to way, and in which way?
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 01:37 PM
test reply, it's not letting me reply
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 01:38 PM
I explained in the original post that the HP value is what determines the person's maxhealth, and if your health < maxhealth, then your stamina value is lowered by the value of your weight. This effect stops when your health = your maxhealth
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
22 Feb 2015 01:40 PM
Human.Changed:connect (function ()
person.leaderstats.HP = Human.MaxHealth
if Human.Health < Human.MaxHealth then
stamina-healthmissing*weight -- lol idk
end
end)
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 04:52 PM
@max where did person come from? I'm still new to scripting but I don't understand why person should be there
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 10:23 PM
So I wrote this and it broke everything.

local Human = game.Workspace:WaitForChild(player.Name):FindFirstChild("Humanoid").Changed
Human.Changed:connect (function ()
local HP = Human.MaxHealth
end)
if Human.Health < Human.MaxHealth then
Stamina.value = Stamina.value - Weight.value
end

None of the stats after I write this are added to the game, I could move it down but also this does not work. I believe it does not work because it calls local Human the humanoid, instead of the maxhealth of the humanoid. How would I make local Human represent Humanoid.MaxHealth instead of just Humanoid?
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
22 Feb 2015 11:00 PM
game.Players.PlayerAdded:connect(function(p)
ldrstat = Instance.new("Model",p)
ldrstat.Name = "leaderstats"

hp = Instance.new("StringValue",ldrstat)
hp.Name = "HP"

p.Character.Humanoid.Changed:connect(function()
hp.Value = p.Character.Humanoid.Health .. "/" .. p.Character.Humanoid.MaxHealth
end)
end)
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 11:08 PM
Legendary why would you change the way my leaderstats work? That makes things so much more confusing now.
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
22 Feb 2015 11:09 PM
"Can leaderstats be linked to a players health/maxhealth?"

That is what I awnsered
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 11:09 PM
I'd just like an edit of the last I posted leading to humanoid.maxhealth instead of just humanoid, as I don't know what to do since firstfindchild was already used.
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 11:10 PM
I guess you did answer this, but there are other stats in mind and I'm trying to learn how to make it work. I did an edit based around what others posted but I'm stuck on this part
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
22 Feb 2015 11:11 PM

game.Players.PlayerAdded:connect(function()

local ls = Instance.new("IntValue",player)
ls.Name = "leaderstats"

local Stamina = Instance.new("IntValue",ls)
Stamina.Value = 100
Stamina.Name = "Stamina"

hp = Instance.new("StringValue",ls)
hp.Name = "HP"

p.Character.Humanoid.Changed:connect(function()
hp.Value = p.Character.Humanoid.Health .. "/" .. p.Character.Humanoid.MaxHealth
end)
end)

there thats your script
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
22 Feb 2015 11:15 PM
fixes

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

local ls = Instance.new("IntValue",player)
ls.Name = "leaderstats"

local Stamina = Instance.new("IntValue",ls)
Stamina.Value = 100
Stamina.Name = "Stamina"

hp = Instance.new("StringValue",ls)
hp.Name = "HP"
repeat wait() until player.Character.Humanoid
hp.Value = math.ceil(player.Character.Humanoid.Health) .. "/" .. math.ceil(player.Character.Humanoid.MaxHealth)
player.Character.Humanoid.Changed:connect(function()
hp.Value = math.ceil(player.Character.Humanoid.Health) .. "/" .. math.ceil(player.Character.Humanoid.MaxHealth)
end)
end)
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 11:16 PM
Well I'd like to learn, not just be spoonfed.

----------------

hp = Instance.new("StringValue",ls)
hp.Name = "HP"

p.Character.Humanoid.Changed:connect(function()
hp.Value = p.Character.Humanoid.Health .. "/" .. p.Character.Humanoid.MaxHealth
end)
end)

-------------

This part confuses me, why is there a .."/"..? Does character mean any player who plays my game? Why did you use stringvalue instead of the stat that I already posted where HP was listed the same way Stamina was?
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
22 Feb 2015 11:23 PM
the .."/".. is going to display like this 100/100 -- see the "/"
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
22 Feb 2015 11:25 PM
I used a string value so I could display it as a string so it can display health and max health in a decent way
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 Feb 2015 11:26 PM
Why not just do "percent health left"? So if they have like a huge Health/MaxHealth value that leaderboard is going to be stretched no?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 Feb 2015 11:28 PM
Not Health/Maxhealth, I meant health or maxhealth sorry
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 11:37 PM
Where will the string value display the health/maxhealth then? The point of HP being on the leaderboard is so people can know the efficiency of armors they are wearing, hence weight also being on the leaderboard.
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
22 Feb 2015 11:41 PM
Look at this place

http://www.roblox.com/LegendaryAccounts-Place-Number-58-place?id=188324974
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
22 Feb 2015 11:54 PM
That's neat, I didn't know you could do that with leaderstats and have never seen it before. Thank you for showing me that. The only other thing that I couldn't get to work, even though I tried in the examples I posted, was getting the value of"Stamina" to lower by the value of "Weight" if you're not at full health.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image