Hello, I have been trying to make a hunger bar. My only problem is that the hunger bar isin't moving. Please help.
Here is my current code:
--{0, 294},{0, 33} to {0, 0},{0, 33} val = Instance.new('IntValue') val.Parent =game.Players.LocalPlayer val.Value = 100 val.Name ="val" val1 = Instance.new('IntValue') val1.Parent =game.Players.LocalPlayer val1.Value = 294 val1.Name = "val1" --script.Parent.Parent.Size = UDim2.new(0,294,0,33) << Here is the script i want help whit. while true do wait(1) script.Parent.Text = val.Value val1.Value = val1.Value - 2.94 val.Value = val.Value - 1 print("VAL: "..val.Value) print("VAL1: "..val1.Value) end
So i'll show you a fix. Follow the following steps: Step Zero (aka description what we need to do 1st): Do step 6. as 1st 1. Make two frames, first is HungerBar (green color) and second is HungerBacking (red color). Their size is {0,5},{0,100} so it takes some long to get your hunger lower. 2. Make a local-script called "ClickFunction". 3. Insert following code there:
local clicker = game.Workspace.mouse.ClickDetector clicker.MouseClick:connect(function() game.Workspace.RemoteEvent:FireServer() end)
while true do script.Parent.HungerBar.Size = UDim2.new(script.Parent.HungerBar.Size.X, script.Parent.HungerBar.Size.Y - 5) wait(1) end
local Tool = script.Parent; enabled = true function onActivated() if not enabled then return end enabled = false local hb = game.Players.LocalPlayer.PlayerGui.ScreenGui.HungerBarr.HungerBar Tool.Handle.DrinkSound:Play() wait(3) local h = Tool.Parent:FindFirstChild("Humanoid") if (h ~= nil) then if (h.MaxHealth > h.Health + 16) then --DO not forget "then" hb.Size.Y = hb.Size + 16 -- Do not delete h.Health = h.Health + 16 else h.Health = h.MaxHealth end end Tool.GripForward = Vector3.new(-.976,0,-0.217) --Do not touch any below Tool.GripPos = Vector3.new(0.03,0,0) Tool.GripRight = Vector3.new(.217,0,-.976) Tool.GripUp = Vector3.new(0,1,0) -- Do not touch any above enabled = true end function onEquipped() Tool.Handle.OpenSound:play() end script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)
Tada! You get a working bar! Have fun :)