its onkey run gui when you press the key "r" its suppose to make you run and the gui bar goes down when keyup it stops going down and recharges to max

Player = script.Parent.Parent.Parent
mouse = Player:GetMouse()
local active = script.Parent.active.Value
local run = script.Parent.run.Value
run = 1
   active = false
function onKeyDown(key)
	key = key:lower()
	if key == "r" then 
		active = true
		if active == true then
for i = 0,1,0.005 do
    wait()
    script.Parent.Frame.ImageLabel.Size = UDim2.new(run -i , 0, 1, 0)
	Player.Character.Humanoid.WalkSpeed = 27
end
end
	end
	end
mouse.KeyDown:connect (onKeyDown)


function onKeyUp(key)
	key = key:lower()
	if key == "r" then 
		print'up'
		active = false
		if active == false then
for i = 0,1,0.005 do
    wait()
    script.Parent.Frame.ImageLabel.Size = UDim2.new(run +i, 0, 1, 0)
	Player.Character.Humanoid.WalkSpeed = 16
end
end
	end
	end
mouse.KeyUp:connect (onKeyUp)

4 comments

0

I suggest you look into proper code formatting and fix that up, it's difficult to read. Are you getting any errors, is the code running at all? Where is this LocalScript located?

0

its in a gui and it does work but it doesnt stop and keyup it goes past the max

0

You're going to have to tell us what the issue you are having is before we can help.

0

I understand the issue, but I don't understand the intent of this code. @OP; what do each of the Values mean?