|
| 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 |
|
|
| |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|