I have a Gui where it shows you energy, thirst etc but the energy bar seems to be going further out than it should, and I don't know how to fix it. It's a localscript.

local p = game.Players.LocalPlayer
local c = p.Character
local m = p:GetMouse()

local sprint = false

local t,f = true,false

local w,a,s,d = f,f,f,f
local wt = 0

m.KeyDown:connect(function(key)
	if key == '0' then
		sprint = t
	end
	if key == 'w' then
		w = t
	end
	if key == 'a' then
		a = t
	end
	if key == 's' then
		s = t
	end
	if key == 'd' then
		d = t
	end
end)
m.KeyUp:connect(function(key)
	if key == '0' then
		sprint = f
	end
	if key == 'w' then
		w = f
	end
	if key == 'a' then
		a = f
	end
	if key == 's' then
		s = f
	end
	if key == 'd' then
		d = f
	end
end)

while wait() do
	wt = wt - .01
	if wt <= 0 then
		if script.Parent.Energy.Size.X.Scale < .9 then
			script.Parent.Energy.Size = script.Parent.Energy.Size + UDim2.new(.005,0,0,0)
		end
	end
	if w or a or s or d then
		if script.Parent.Energy.Size.X.Scale > 0 and sprint then
			script.Parent.Energy.Size = script.Parent.Energy.Size - UDim2.new(.005,0,0,0)
			c.Humanoid.WalkSpeed = 30
		end
	end
	if sprint then
		wt = 1.3
	end
	if not w and not a and not s and not d then c.Humanoid.WalkSpeed = 16 end
	if not sprint then c.Humanoid.WalkSpeed = 16 end
	if script.Parent.Energy.Size.X.Scale <= 0 then c.Humanoid.WalkSpeed = 16 end
end

It does this: https://gyazo.com/6005c1f028849761c9aadec0d0e0bff0

5 comments

0

Please post un-obfuscated scripts please

0

"un-obfuscated"

0

How else am I meant to make it clearer? That's what I wrote. I can't make it any clearer. God almighty.

0

The bar is a child to the status frame, right?

0

Yes