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 » Scripters
Home Search
 

Re: HUNGER BAR AND REGENERATE HUNGER:

Previous Thread :: Next Thread 
thegoodpuppy is not online. thegoodpuppy
Joined: 07 Jul 2011
Total Posts: 2737
29 Aug 2016 10:34 PM
Here's how it is, so I have a part in workspace with a surfacegui inside it, and a text button inside it. What I want, is so when I click the text button, the "hunger" goes to 100. I have all it all right, it's just the scripts:

Inside the hunger bar:
--If hunger = 0 this kills the player.--
while wait() do
if script.Parent.Value.Value == 0 then
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").Health = 0
end
end

Inside the hunger bar:
--This haves it so negative signs aren't shown and to make sure if it does happen, the player dies.--
while wait() do
if script.Parent.Value.Value <= 0 then
script.Parent.Value.Value = 0
end
end

Inside the hunger bar:
--This haves it so the hunger bar shows "Hunger:", then the value which is the hunger.(By the way the hunger value starts at 100 at the join of the game and the respawn of a player)--
while wait() do
script.Parent.Text = ("Hunger:"..script.Parent.Value.Value)
end

Inside PlayerGui:
--This haves it so every ten seconds someone loses a "hunger" value.--
while true do
wait(10)
script.Parent.Hunger.TextLabel.Value.Value = script.Parent.Hunger.TextLabel.Value.Value - 1
end

Inside a text button, the text button is inside a surfacegui, and the surfacegui is inside a part:
--I am TRYING to make it, so if a players "wood" is 5, then when they hit this they lose 5 wood and get their hunger to 100, it does not get their wood to 100, it gets their wood to stay that same.
function gettingfed()
if game.Workspace.WoodPart.SurfaceGui.TextLabel.Value.Value >= 5 then
game.Players.LocalPlayer.PlayerGui.Hunger.TextLabel.Value.Value = 100
game.Workspace.WoodPart.SurfaceGui.TextLabel.Value.Value = game.Workspace.WoodPart.SurfaceGui.TextLabel.Value.Value - 5
else--(PLEASE IGNORE THE SPACING BETWEEN THE TWO LINES ABOVE, THE FORUM SIZING DOES THAT)
end
end

script.Parent.MouseButton1Click:connect(gettingfed)

--So, I do not know WHAT is wrong with these scripts, but it does not get the hunger to 100 when "fed". Everything else works, though. When I click the button to get fed, I don't lose wood, and I don't get "fed".

Report Abuse
thegoodpuppy is not online. thegoodpuppy
Joined: 07 Jul 2011
Total Posts: 2737
29 Aug 2016 10:37 PM
By the way, there are no errors in the output.
Report Abuse
Boyinblack010403 is not online. Boyinblack010403
Joined: 16 Jul 2015
Total Posts: 118
30 Aug 2016 08:48 AM
What's the else in the end for ???
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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