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: I have this health script, but how do I keep it constant?

Previous Thread :: Next Thread 
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 04:25 PM
This script is made so it bases your health on the leaderboard

------

game.Players.ChildAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
char.Humanoid.MaxHealth = player.leaderstats.Weight.Value
end)
end)

----

but if weight changes, the maxhealth stays the same. How should I make it so the maxhealth would change with the value of weight?
Report Abuse
KlinkStudios is not online. KlinkStudios
Joined: 31 Oct 2013
Total Posts: 563
25 Feb 2015 04:26 PM
Use events.
Report Abuse
gerov is not online. gerov
Joined: 05 Feb 2011
Total Posts: 5504
25 Feb 2015 04:27 PM
player.leaderstats.Weight.Value.Changed:connect(function()
--do stuff
end)

Why don't you take a seat over there?
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
25 Feb 2015 04:27 PM
Weight.Changed
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
25 Feb 2015 04:27 PM
@gerov
Wouldn't work because .Changed works with an instance and not with a number.
Report Abuse
GreedTaka is not online. GreedTaka
Joined: 12 Dec 2014
Total Posts: 1503
25 Feb 2015 04:28 PM
local player = game.Players.LocalPlayer
local g = player.leaderstats.Weight.Value

function Key()
char.Humanoid.MaxHealth = player.leaderstats.Weight.Value
end

Key()
g.Changed:connect(Key)
Report Abuse
GreedTaka is not online. GreedTaka
Joined: 12 Dec 2014
Total Posts: 1503
25 Feb 2015 04:29 PM
char = player.Character
Report Abuse
gerov is not online. gerov
Joined: 05 Feb 2011
Total Posts: 5504
25 Feb 2015 04:33 PM
@Lolid Oh :p, I have never used it, so I was just guessing how it would work.

Why don't you take a seat over there?
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 05:20 PM
So here's my attempt

game.Players.ChildAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
char.Humanoid.MaxHealth = player.leaderstats.Weight.Value
player.leaderstats.Weight.Value.Changed:connect(function()
char.Humanoid.MaxHealth = player.leaderstats.Weight.newValue
end)
end)
end)

It makes your weight your hp, but if weight changes, your hp doesn't until you reset. I can't have my players resetting all of the time, so the issue still exist.
Report Abuse
GreedTaka is not online. GreedTaka
Joined: 12 Dec 2014
Total Posts: 1503
25 Feb 2015 05:56 PM
you numbskull i just gave you the script
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 06:05 PM
I tried it and it didn't work. I may have not done it how you wanted, as I might be a numbskull but could you try to be more clear?
Report Abuse
GreedTaka is not online. GreedTaka
Joined: 12 Dec 2014
Total Posts: 1503
25 Feb 2015 06:14 PM
local player = game.Players.LocalPlayer --if this dont work chage from local to function
local char = player.Character
local g = player.leaderstats.Weight.Value

function Key()
char.Humanoid.MaxHealth = player.leaderstats.Weight.Value
end

Key()
g.Changed:connect(Key)


this should work
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 06:16 PM
local player = game.Players.LocalPlayer
local g = player.leaderstats.Weight.Value

function Key()
char.Humanoid.MaxHealth = player.leaderstats.Weight.Value
end

Key()
g.Changed:connect(Key)
char = player.Character

----

This doesn't work.
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 06:20 PM
Your latest doesn't work either, could you test it in your game?
Report Abuse
GreedTaka is not online. GreedTaka
Joined: 12 Dec 2014
Total Posts: 1503
25 Feb 2015 06:24 PM
local player = game.Players.LocalPlayer
local char = player.Character -0000---------------------------this is not on that
local g = player.leaderstats.Weight.Value

function Key()
char.Humanoid.MaxHealth = player.leaderstats.Weight.Value
end

Key()
g.Changed:connect(Key)

look up at the comment
ill test just in case
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 06:48 PM
I got nothing from that script either.
Report Abuse
GreedTaka is not online. GreedTaka
Joined: 12 Dec 2014
Total Posts: 1503
25 Feb 2015 06:50 PM
oops i apologize remove game.players.local player that only works for local scripts

and add parents instead im pretty sure theres 2 or 3
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 07:34 PM
I still know very little about scripting to know what you want :/

I'm good at linking things that already have a foundation but creating new things isn't in my skillset yet.l
Report Abuse
GreedTaka is not online. GreedTaka
Joined: 12 Dec 2014
Total Posts: 1503
25 Feb 2015 07:53 PM
local player = game.Players.LocalPlayer
local char = game.Players:getPlayerFromCharacter()
local g = player.leaderstats.Weight.Value

function Key()
char.Humanoid.MaxHealth = player.leaderstats.Weight.Value
end

Key()
g.Changed:connect(Key)
Report Abuse
killette2 is not online. killette2
Joined: 16 Sep 2009
Total Posts: 3502
25 Feb 2015 09:45 PM
Still not doing anything, it doesn't have any errors in the script the script just isn't doing what it should. I run a test, check my humanoid and it's 100, change weight still 100, reset, still 100.
Report Abuse
bluebird1287 is not online. bluebird1287
Joined: 16 Jun 2011
Total Posts: 4202
25 Feb 2015 09:48 PM
Disregard all the other attempts of help
And focus on this easy alternative!
Put a gui in the StarterGui
put a script in it
then in the script make it




while true do
player = script.Player.Player.Player --Make sure script is in the gui, not a frame.
Wei = player.leaderstats.Weight.Value

player.Character.Humanoid.MaxHealth.Value = Wei

wait()
end
Report Abuse
TooKawaiiForSenpai is not online. TooKawaiiForSenpai
Joined: 03 Mar 2009
Total Posts: 3241
25 Feb 2015 09:49 PM
You made the same exact post yesterday and I answered it then
http://www.roblox.com/Forum/ShowPost.aspx?PostID=156714084
Report Abuse
bluebird1287 is not online. bluebird1287
Joined: 16 Jun 2011
Total Posts: 4202
25 Feb 2015 09:49 PM
Remove the .Value from the line "MaxHealth.Value"
because that's incorrect.

Report Abuse
bluebird1287 is not online. bluebird1287
Joined: 16 Jun 2011
Total Posts: 4202
25 Feb 2015 09:50 PM
omfg


I scripted that like a noob


let me repair it omg




while true do

player = script.Parent.Parent.Parent
wei = player.leaderstats.Weight.Value

wait()
player.Character.Humanoid.MaxHealth = wei

end
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
25 Feb 2015 09:54 PM
Put this code inside of a LocalScript.

Put the script into StarterGui.


local Player = game.Players.LocalPlayer
while Player.Character == nil do wait() end
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")

local Weight = Player.leaderstats.Weight
Weight.Changed:connect(function()
Humanoid.MaxHealth = Weight.Value
Humanoid.Health = Humanoid.MaxHealth -- Assigns current health to new maxhealth, remove this line if this consequence is undesired
end)
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