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: Whats wrong in this script? Please help!

Previous Thread :: Next Thread 
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
25 Jan 2014 03:19 AM
Hi! I'm creating a survival game but the script of hunger and water isn't working!
Please help!

Script:

game.Players.PlayerAdded:connect(function(player)
-- HP
local HP = Instance.new("IntValue", player)
HP.Name = "HP"
HP.Value = 100;
-- Hunger
local Hunger = Instance.new("IntValue", player)
Hunger.Name = "Hunger"
Hunger.Value = 100;
-- Water
local Water = Instance.new("IntValue", player)
Water.Name = "Water"
Water.Value = 100;
-- Lose Hunger and Water
while wait(3) do
Water = Water - 2;
Hunger = Hunger - 2;
if Hunger < 0 then
HP = 0
else if Water < 0 then
HP = 0
end
end
if HP <= 0 then
player.Character.Humanoid.Health = 0
end
end
end)
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
25 Jan 2014 03:31 AM
Someone? D:
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
25 Jan 2014 03:40 AM
Please help ):
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
25 Jan 2014 03:40 AM
Well i am not the best at break down why scripts are wrong but I do see or would recommend something I could make the a script that you can base it off of

First off you want a local script that define Stats and what they are and give them to player

Then a gui and a script that calls for the stats and actually makes them loose health and stuff witch then you can make bars ect ect

Sorry if i was not much help but thats what i would do
Report Abuse
Wreckerbuster67 is not online. Wreckerbuster67
Joined: 29 Jul 2012
Total Posts: 1144
25 Jan 2014 03:40 AM
game.Players.PlayerAdded:connect(function(plr)
local stats=Instance.new("IntValue", plr)
stats.Name="leaderstats"

local HP=Instance.new("IntValue", stats)
HP.Name="Health"
HP.Value=100

local Hunger=Instance.new("IntValue", stats)
Hunger.Name="Hunger"
Hunger.Value=100

local Water=Instance.new("IntValue", stats)
Water.Name="Thirst"
Water.Value=100

while wait(3) do
Hunger.Value=Hunger.Value-2
Water.Value=Water.Value-2

if Hunger.Value<1 or Water.Value<1 then
HP.Value=0
end
end

HP.Value.Changed:connect(function()
if HP.Value==0 then
plr.Character.Humanoid:TakeDamage(plr.Character.Humanoid.MaxHealth)
end
end)
end)
Report Abuse
GamerOfGames123 is not online. GamerOfGames123
Joined: 14 Jul 2012
Total Posts: 210
25 Jan 2014 04:24 AM
Thaaaank youuuuuu :D
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