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 » Scripting Helpers
Home Search
 

Re: Can somone remind me how to do this?

Previous Thread :: Next Thread 
ninjafang7818292 is not online. ninjafang7818292
Joined: 11 Sep 2010
Total Posts: 504
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
ninjafang7818292 is not online. ninjafang7818292
Joined: 11 Sep 2010
Total Posts: 504
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 is not online. 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
ninjafang7818292 is not online. ninjafang7818292
Joined: 11 Sep 2010
Total Posts: 504
05 Aug 2013 01:40 PM
Why didn't I think of that! Thankyou. :)
Report Abuse
johnhugh is not online. 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 is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
05 Aug 2013 01:43 PM
^

Humanoid.Died:connect(function()
end)
Report Abuse
ninjafang7818292 is not online. ninjafang7818292
Joined: 11 Sep 2010
Total Posts: 504
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
ninjafang7818292 is not online. ninjafang7818292
Joined: 11 Sep 2010
Total Posts: 504
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
ninjafang7818292 is not online. ninjafang7818292
Joined: 11 Sep 2010
Total Posts: 504
05 Aug 2013 02:17 PM
Nvm, I figured it out.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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