in short, i made a script that lets you run when pressing shift, and lets you walk when you let go.
you are able to run when an Intvalue is more than 0, and it increases every second by 1 when not running.
However, if you press shift two times under a second, the intvalue increases by 1 TWICE every second. from my understanding , the script malfunctions and runs the same line twice.
(the main bug starts at line 30)
repeat wait() until game.Players.LocalPlayer
local running = false
local amount = game.StarterGui.run.Value.Value
local function stoprunning()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 11
end
m = game.Players.LocalPlayer:GetMouse()
m.KeyDown:connect(function(key)
if key == "0" and running == false then
print("Running")
running = true
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 22
while running == true do
game.StarterGui.run.Value.Value = math.clamp(game.StarterGui.run.Value.Value - 1, 0, 100)
local amount = game.StarterGui.run.Value.Value
print (amount)
wait(0.1)
if amount == 0 then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 11
end
end
end
end)
m.KeyUp:connect(function(key)
if key == "0" and running == true then
running = false
local amount = game.StarterGui.run.Value.Value
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 11
while running == false do
local amount = game.StarterGui.run.Value.Value
game.StarterGui.run.Value.Value = math.clamp(game.StarterGui.run.Value.Value + 1, 0, 100)
print(amount)
wait(0.9)
end
end
end)

2 comments
you have to rewrite your code to use UserInputService instead, Mouse is being Deprecated, Mouse should only be used in Plugins and Tools.
Mouse is NOT being deprecated, but KeyUp/KeyDown are deprecated and UserInputService.InputBegan should be used instead