Why script no work? (Stamina)

Hello devs

  1. What do you want to achieve? A working mobile stamina sprint button

  2. What is the issue? Mobile button is not appearing, I do not know what the problem is. No errors in output

  3. What solutions have you tried so far? Looked for tutorials, none helped me, nor could I find any good ones

local Bar = script.Parent:WaitForChild('Background'):WaitForChild('Bar')

local player = game.Players.LocalPlayer

local NormalWalkSpeed = 16
local NewWalkSpeed = 30

local power = 10

local sprinting = false

repeat wait() until game.Players.LocalPlayer.Character

local character = player.Character



local contextActionService = game:GetService("ContextActionService")
local playerName = script.Parent.Parent.Name
local sprintValue = Instance.new("BoolValue")
sprintValue.Parent = script
local sprint = sprintValue.Value
function onButtonPress()
	
	function onButtonPress(inputName, inputState)
		if inputState == Enum.UserInputState.Begin then
			character.Humanoid.WalkSpeed = NewWalkSpeed
			sprinting = true
			while power > 0 and sprinting do
				power = power - .1
				Bar:TweenSize(UDim2.new(power / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
				Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 42, 42), 0.001)
				wait()
				if power <= 0 then
					character.Humanoid.WalkSpeed = NormalWalkSpeed
					
				elseif inputState == Enum.UserInputState.End then
					character.Humanoid.WalkSpeed = NormalWalkSpeed
					sprinting = false
					while power < 10 and not sprinting do
						power = power + .03
						Bar:TweenSize(UDim2.new(power / 10, 0, 1, 0), 'Out', 'Quint', .1, true)
						Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 166, 11), 0.001)
						wait()
						if power <= 0 then
							character.Humanoid.WalkSpeed = NormalWalkSpeed
		end
	end
end
end
local mobilebutton = contextActionService:BindAction("SprintButton",onButtonPress,true,"Sprint")
contextActionService:SetPosition("SprintButton",UDim2.new(0.72,-25,0.20,-25))
contextActionService:SetImage("SprintButton","rbxassetid://2572666627")

		end
	end
	end

Any improvements to the script would be helpful

thanks for reading

What’s the problem? You just said “something in the script is not working”, what does that mean?

My bad, I mean the mobile button is not appearing