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: Controlling MaxHealth via leaderstats

Previous Thread :: Next Thread 
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
24 Feb 2015 09:59 PM
How would I do this? I tried writing this script to make it 1 for example, but it does not work.

-----

local Weight = Instance.new("IntValue",ls)
Weight.Value = 1
Weight.Name = "Weight"

HP = Instance.new("StringValue",ls)
HP.Name = "HP"
repeat wait() until player.Character.Humanoid
player.Character.Humanoid.Changed:connect(function()
HP.Value = (player.Character.Humanoid.MaxHealth)
player.Character.Humanoid.MaxHealth = Weight.Value
end)
Report Abuse
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
24 Feb 2015 10:07 PM
I don't know if this is th ereason or not, but Weight is an Integer Value which means it has to be a whole number. Players' Health are usually not an integer when healing.
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
24 Feb 2015 10:08 PM
I'm pretty sure if you try to assign a Float value to an Integer in Lua it'll just clamp it.
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
24 Feb 2015 10:11 PM
local Health = 100
local MaxHealth = 100

local Leaderstats = Instance.new("StringValue") --parent this to the player
local HealthValue = Instance.new("NumberValue", leaderstats)
HealthValue.Name = "HP"
HealthValue.Value = Health

myPlayer.Character.Humanoid.HealthChanged(newHealth) -- you need to use healthchanged like this
health = newHealth
HealthValue.Value = health
end
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
24 Feb 2015 10:31 PM
Putting that in just breaks my whole leaderboard. It works like this currently

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

function onPlayerEntered(player)

--stats

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

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

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

local Endurance = Instance.new("IntValue",ls)
Endurance.Value = 1
Endurance.Name = "Endurance"


------------------
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
24 Feb 2015 10:41 PM
In his script replace MyPlayer with player
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
24 Feb 2015 11:23 PM
Ok I wrote this

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

local MaxHealth = 99

local HealthValue = Instance.new("NumberValue", ls)
HealthValue.Name = "HP"
HealthValue.Value = Maxhealth

Player.Character.Humanoid.HealthChanged(newHealth) -- you need to use healthchanged like this
MaxHealth = newHealth
HealthValue.Value = MaxHealth
end

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

But it breaks the end at the very end of my script and I don't know why.
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
24 Feb 2015 11:47 PM
The whole script

----

function onPlayerEntered(player)

--stats

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

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

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

local Endurance = Instance.new("IntValue",ls)
Endurance.Value = 1
Endurance.Name = "Endurance"

local Enduranceexp = Instance.new("IntValue",Endurance)
Enduranceexp.Value = 0
Enduranceexp.Name = "Enduranceexp"

Enduranceexp.Changed:connect(function()
Endurance.Value = Enduranceexp.Value^.5
end)

local Weight = Instance.new("IntValue",ls)
Weight.Value = 1
Weight.Name = "Weight"

local MaxHealth = 99

local HealthValue = Instance.new("NumberValue",ls)
HealthValue.Name = "HP"
HealthValue.Value = Maxhealth

Player.Character.Humanoid.HealthChanged(newHealth) -- you need to use healthchanged like this
MaxHealth = newHealth
HealthValue.Value = MaxHealth
end

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

local Plantlore = Instance.new("IntValue",ls)
Plantlore.Value = 1
Plantlore.Name = "Plantlore"

local Plantloreexp = Instance.new("IntValue",Plantlore)
Plantloreexp.Value = 1
Plantloreexp.Name = "Plantloreexp"

Plantloreexp.Changed:connect(function()
Plantlore.Value = Plantloreexp.Value^.5
end)

local Fishing = Instance.new("IntValue",ls)
Fishing.Value = 1
Fishing.Name = "Fishing"

local Fishingexp = Instance.new("IntValue",Fishing)
Fishingexp.Value = 1
Fishingexp.Name = "Fishingexp"

Fishingexp.Changed:connect(function()
Fishing.Value = Fishingexp.Value^.5
end)

local Cooking = Instance.new("IntValue",ls)
Cooking.Value = 1
Cooking.Name = "Cooking"

local Cookingexp = Instance.new("IntValue",Cooking)
Cookingexp.Value = 1
Cookingexp.Name = "Cookingexp"

Cookingexp.Changed:connect(function()
Cooking.Value = Cookingexp.Value^.5
end)

local Mining = Instance.new("IntValue",ls)
Mining.Value = 1
Mining.Name = "Mining"

local Miningexp = Instance.new("IntValue",Mining)
Miningexp.Value = 1
Miningexp.Name = "Miningexp"

Miningexp.Changed:connect(function()
Mining.Value = Miningexp.Value^.5
end)

local Smithing = Instance.new("IntValue",ls)
Smithing.Value = 1
Smithing.Name = "Smithing"

local Smithingexp = Instance.new("IntValue",Smithing)
Smithingexp.Value = 1
Smithingexp.Name = "Smithingexp"

Smithingexp.Changed:connect(function()
Smithing.Value = Smithingexp.Value^.5
end)

local Magic = Instance.new("IntValue",ls)
Magic.Value = 1
Magic.Name = "Magic"

local Magicexp = Instance.new("IntValue",Magic)
Magicexp.Value = 1
Magicexp.Name = "Magicexp"

Magicexp.Changed:connect(function()
Magic.Value = Magicexp.Value^.5
end)

local Mana = Instance.new("IntValue",ls)
Mana.Value = 10
Mana.Name = "Mana"

local Intel = Instance.new("IntValue",ls)
Intel.Value = 1
Intel.Name = "Intel"

local Intelexp = Instance.new("IntValue",Intel)
Intelexp.Value = 1
Intelexp.Name = "Intelexp"

Intelexp.Changed:connect(function()
Intel.Value = Intelexp.Value^.5
end)

local Aura = Instance.new("IntValue",ls)
Aura.Value = 0
Aura.Name = "Aura"

end
game.Players.ChildAdded:connect(onPlayerEntered)
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
24 Feb 2015 11:57 PM
So why won't it work?
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 01:15 AM
bump
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 01:25 AM
I just want help...
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 02:34 AM
Bump...
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