Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 08 Apr 2013 06:14 PM |
local h = game.Players.LocalPlayer.Character.Humanoid h.Changed:connect(function() script.Parent.Size = UDim2.new(0,(h.Health*1.5),0.02,0) end)
It gives this error 19:11:59.341 - Players.Player1.PlayerGui.MainGui.Health.Health.LocalScript:1: attempt to index field 'Character' (a nil value)
But if I disable/re-enable it there is no error. |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2013 06:15 PM |
| add a wait(0.1) to the top. |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2013 06:15 PM |
put this at the top
repeat wait() until game.Players.LocalPlayer.Character |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2013 06:16 PM |
| wait(0.1) still wont work on people with really slow computers. |
|
|
| Report Abuse |
|
|
Kondou
|
  |
| Joined: 05 Aug 2012 |
| Total Posts: 1148 |
|
|
| 08 Apr 2013 06:18 PM |
repeat wait() until game.Players.LocalPlayer.Character
Worked, thanks. |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2013 06:18 PM |
Actually, do this:
p=game.Players.LocalPlayer p.CharacterAdded:connect(function(char) char:FindFirstChild("Humanoid").Changed:connect(function() script.Parent.Size = UDim2.new(0,(h.Health*1.5),0.02,0) end) end) |
|
|
| Report Abuse |
|
|