|
| 29 Jun 2016 07:24 PM |
This was working fine until I moved it into PlayerGui.
Code: local Gui = script.Parent --ImageLabel local Player = game.Players.LocalPlayer local Character = game.Players.LocalPlayer.Character
Character.Humanoid.HealthChanged:connect(function() Gui.Position = UDim2.new(((Character.Humanoid.Health / Character.Humanoid.MaxHealth)*.129),0,0.075,0) end)
ERROR: 20:22:08.905 - Players.Player1.PlayerGui.player_frame.Frame.Health.health_script:5: attempt to index local 'Character' (a nil value) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 29 Jun 2016 10:13 PM |
local Character = Player.Character
i steal usernames, any user who talks to me is the username i stole |
|
|
| Report Abuse |
|
|
| |
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 29 Jun 2016 10:15 PM |
the character does not always load right away, you will need to wait for it
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
zectec
|
  |
| Joined: 24 Sep 2012 |
| Total Posts: 285 |
|
|
| 29 Jun 2016 10:16 PM |
Umm is this a typo? "Character.Humanoid.HealthChanged:connect(function()"
You forgot to put a dot where it says HealthChanged
Like this Health.Changed
|
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 29 Jun 2016 10:17 PM |
^ wrong, HealthChanged is an event
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
|
| 29 Jun 2016 10:24 PM |
Fixed first issue! And now, we have another! The green bar goes down the first time the HP is damaged, then every time it's damaged after the first time the green bar goes up when it's damaged.
LocalScript Code: local Gui = script.Parent --ImageLabel local Player = game.Players.LocalPlayer local Character = Player.Character
wait(5)
Character.Humanoid.HealthChanged:connect(function() Gui.Position = UDim2.new(((Character.Humanoid.Health / Character.Humanoid.MaxHealth)*.129),0,0.075,0) end) |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 29 Jun 2016 10:26 PM |
I don't know how you do things, but I like to use TweenSize() and just move the bar down by X amount as the player takes damage.
u sicko! |
|
|
| Report Abuse |
|
|
|
| 29 Jun 2016 10:51 PM |
| what's tweensize() do? I looked it up, I barley see anything about it. |
|
|
| Report Abuse |
|
|
|
| 29 Jun 2016 10:53 PM |
basically it's like the scriptable version of the resize tool.
i steal usernames, any user who talks to me is the username i stole |
|
|
| Report Abuse |
|
|
Sycronox
|
  |
| Joined: 07 Jul 2013 |
| Total Posts: 29 |
|
|
| 29 Jun 2016 10:58 PM |
TweenSize(UDim2.new()) and TweenPosition(UDim2.new()) are basically gui animations. TweenSize changes the gui size with an animation and TweenPosition changes the position with an animation as well.
You can look up this information on the ROBLOX wiki.
|
|
|
| Report Abuse |
|
|