-
What do you want to achieve? A simple sprint button for mobile players
-
What is the issue? Players clicking on the button does nothing at least not even changing the text.
-
What solutions have you tried so far? Tried debugging when the text change but it does not even print.
local function sprint()
if string.lower(toggletxt) == "Walk" then
if Humanoid.MoveDirection.Magnitude > 0 then
if not (character.Humanoid.WalkSpeed <= 7) then
toggletxt = "sprint"
sprinting = true
while stamina > 0 and stamina do
stamina = stamina - .03
Bar.Size = UDim2.new(stamina / 10, 0, 1, 0)
tween:Play()
wait()
if stamina <= 0 then
tween2:Play()
runninganim:Stop()
sprinting = false
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end
elseif string.lower(toggletxt) == "Sprint" then
if not (character.Humanoid.WalkSpeed <= 7) then
toggletxt = "walk"
character.Humanoid.WalkSpeed = NormalWalkSpeed
sprinting = false
runninganim:Stop()
while stamina < 10 and not sprinting do
stamina = stamina + .03
Bar.Size = UDim2.new(stamina / 10, 0, 1, 0)
tween2:Play()
wait()
if stamina <= 0 then
tween2:Play()
runninganim:Stop()
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end
if character.Humanoid.WalkSpeed == 0 and runninganim.IsPlaying then
runninganim:Stop()
end
end
button.MouseButton1Down:Connect(sprint)
thanks in advance!