KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 10:45 AM |
I removed the standard Health GUI from my game and added my own. When Hunger/Thirst bars are fully depleted, they begin too deplete the Health GUI. When the Health GUI is fully depleted, this script should kill the player:
healthy = script.Parent.Size.X.Offset h = script.Parent.Parent.Parent.Parent.Parent.Parent:findFirstChild("Humanoid")
while wait(.1) do if healthy <= 0 then h.Health = 0 end end
However, it doesn't work. The script is in StarterGui > ScreenGui > Frame > Frame > Frame That final frame that the script is directly inside of contains the "healthy" variable, the size of the bar which is depleted by other scripts.
Help? |
|
|
| Report Abuse |
|
|
Froco
|
  |
| Joined: 07 Aug 2011 |
| Total Posts: 8812 |
|
|
| 19 Jul 2014 10:55 AM |
| healthy -- This part is Messed up capitalize that part, and it could be spelt wrong "Healthy" |
|
|
| Report Abuse |
|
|
Froco
|
  |
| Joined: 07 Aug 2011 |
| Total Posts: 8812 |
|
|
| 19 Jul 2014 10:58 AM |
while wait() do for i,v in pairs(game.Players:GetPlayers()) do if v.PlayerGui:FindFirstChild("HealthGUI") ~= nil then v.PlayerGui.HealthGUI:Destroy() end end wait(0.1) end |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 11:04 AM |
1: You cant make a variable a reference to a property, only point to the current value of the property.
2: Make the GUI linked to the Humanoid's Health, NOT the other way around. |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 02:01 PM |
@Froco, I don't see why the variable would have to be capitalized.
@Not, couldn't I make the variable a reference to the property by putting it inside of the script, like this?:
h = script.Parent.Parent.Parent.Parent.Parent.Parent:findFirstChild("Humanoid")
while wait(.1) do healthy = script.Parent.Size.X.Offset if healthy <= 0 then h.Health = 0 end end
(It still doesn't work by the way, I don't really know how to remove health like this) |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 02:04 PM |
script.Parent.Parent.Parent.Parent.Parent.Parent:findFirstChild("Humanoid")
What are you doing? xD
And yes, you could. But like I said, base the bar's Size off of the Humanoid's Health, not the other way around. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 02:09 PM |
while true do wait() script.Parent.Size = UDim2.new(PathToPlayer.Character.Humanoid.Health/PathToPlayer.Character.Humanoid.MaxHealth,0,1,0)
The life of a man, can be taken so quickly. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 02:09 PM |
while true do wait() script.Parent.Size = UDim2.new(PathToPlayer.Character.Humanoid.Health/PathToPlayer.Character.Humanoid.MaxHealth,0,1,0) end
Forgot an end whoops
The life of a man, can be taken so quickly. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 02:18 PM |
Ziruto, don't, pls, you're killing me with that.
humanoid.HealthChanged
owait im a hypocrite |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 03:10 PM |
Oh.
The problem (For me, at least) with doing it this way is that the Hunger/Thirst GUIs will begin to deplete the Health GUI, but not the player's health.
And I don't know how to get them to deplete the player's health. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 03:12 PM |
| Humanoid:TakeDamage(math.huge - 1) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 03:23 PM |
| How does it find the player's humanoid like that though, without looking for it specifically? |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 03:49 PM |
| game.Players.LocalPlayer.Character.Humanoid |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
| |
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 05:37 PM |
| So math.huge - 1 would remove all Health? |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 05:41 PM |
| math.huge would (math.huge - 1 was just a joke, as infinity minus one is still infinity) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 06:02 PM |
Alright, I'm pretty sure I got the Health script working, but when I changed the Hunger script to not depletemy Health GUI, but instead deplete actual Health, it did not work.
local hunger = script.Parent.Size.X.Offset local ts = script.Parent.Size
while wait (.04) do local healthe = game.Players.LocalPlayer.Character.Humanoid.Health if hunger > 0 then hunger = hunger - 10--.007 script.Parent.Size = UDim2.new(ts.X.Scale,hunger,ts.Y.Scale,ts.Y.Offset) else if healthe > 0 then healthe = healthe - 1 end end end
Is the healthe variable incorrect? |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2014 06:08 PM |
local humanoid = game.Players.LocalPlayer.Character.Humanoid
if hunger <= 0 then humanoid:TakeDamage(1) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 06:25 PM |
| Thanks a ton, it now works perfectly. |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 06:28 PM |
wait up
Unfortunately I have to take that back.
It works perfectly in Studio's Test>Play Solo (Hunger/Thirst bars deplete, Health depletes, death occurs).
In the actual game, your Hunger/Thirst don't deplete at all.
Do you know why the actual game be different than testing in Studio?
|
|
|
| Report Abuse |
|
|
| |
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Jul 2014 06:32 PM |
| That worked, thanks for all the help :) |
|
|
| Report Abuse |
|
|