|
| 05 Aug 2013 01:18 PM |
I forgot how to do the event where if the character dies. I am so forgetful sometimes. But I have a Health/Thirst GUI. the problem is that once the Hunger/Thirst bar is to 0. The character dies although the Hunger/Thirst Bar is still at 0. How would I get it to reset.
P.S. I'm bad at explaining things as well....
Here are the snippets of the script.
If you need another snippet just ask.
Variables-
for i=1, #players do local stats = players[i]:findFirstChild("Stats") if (stats ~= nil) then local hunger = stats:findFirstChild("Hunger") local thirst = stats:findFirstChild("Thirst")
Death function-
if (hunger.Value <= 0 or thirst.Value <= 0) then local human = players[i].Character:findFirstChild("Humanoid") if (human ~= nil) then human.Health = 80 wait(3) human.Health = 60 wait(3) human.Health = 40 wait(3) human.Health = 20 wait(3) human.Health = 0 end end end end end
|
|
|
| Report Abuse |
|
|
|
| 05 Aug 2013 01:37 PM |
Bump.
All I need to know is the "on death" function and how to make the Hunger and Thirst back to 100... |
|
|
| Report Abuse |
|
|
Voxels
|
  |
| Joined: 02 Jan 2012 |
| Total Posts: 24 |
|
|
| 05 Aug 2013 01:39 PM |
If you want everything to go back when you die couldn't you just put everything in the starter gui?
(lol, yes, I don't know what I'm talking about) |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2013 01:40 PM |
| Why didn't I think of that! Thankyou. :) |
|
|
| Report Abuse |
|
|
johnhugh
|
  |
| Joined: 26 Mar 2009 |
| Total Posts: 1971 |
|
|
| 05 Aug 2013 01:41 PM |
Died function is player.Died (or maybe Character.Died?) hunger.Value = 100 thirst.Value = 100 |
|
|
| Report Abuse |
|
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 05 Aug 2013 01:43 PM |
^
Humanoid.Died:connect(function() end) |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2013 01:59 PM |
local timeToUpdate = 10 local amt = 5
while (true) do wait(timeToUpdate) local players = game.Players:GetChildren()
for i=1, #players do local stats = players[i]:findFirstChild("Stats") if (stats ~= nil) then local hunger = stats:findFirstChild("Hunger") local thirst = stats:findFirstChild("Thirst")
if (hunger.Value - amt < 0) then hunger.Value = 0 else hunger.Value = hunger.Value - amt end
if (thirst.Value - amt < 0) then thirst.Value = 0 else thirst.Value = thirst.Value - amt end
if (hunger.Value <= 0 or thirst.Value <= 0) then local human = players[i].Character:findFirstChild("Humanoid") if (human ~= nil) then human.Health = 80 wait(3) human.Health = 60 wait(3) human.Health = 40 wait(3) human.Health = 20 wait(3) human.Health = 0 Humanoid.Died:connect(function(Died) -- Like this? hunger.Value = 100 thirst.Value = 100 end) end end end end end |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2013 02:03 PM |
That did not work either...
By the way. There are two scripts.
The one I posted above and this one:
function Entered(player) wait()
if player:findFirstChild("Stats") ~= nil then player:findFirstChild("Stats"):remove() end stats = Instance.new("IntValue") stats.Parent = player stats.Name = "Stats"
---------------Stats------------ v = Instance.new("IntValue") v.Parent = stats v.Name = "Hunger" v.Value = 100
v = Instance.new("IntValue") v.Parent = stats v.Name = "Thirst" v.Value = 100
end
game.Players.PlayerAdded:connect(Entered)
c = game.Players:GetChildren() for i=1, #c do Entered(c[i]) end
|
|
|
| Report Abuse |
|
|
| |
|