Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Local Sprinting script?

Asked by 9 years ago

I am trying to make a sprinting script but it is very unreliable. So the idea was to make a script when you press Shift you start getting higher movement speed (gradually going up instead of a instant movement speed boost)

The problem I am having now is that when i release the Shift button the speed sometimes stays in the speed it is at that moment. Instead of gradually going down. The only way this script works now is when i press shift hold it until the max speed has been reached (30.7) And then release the button it goes back to 16. How do i make this local script work? (Feel free to test this script out in Roblox Studio)

I have almost tried everything to make this work but since i have been working on this one script for over 6 hours now i am getting more and more confused.

Any help is appreciated if you have a suggestion to code this in a other way that would be fine too. Thanks in advance. -Theburnboss

local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Character = Player.Character
local sprintmulti = 0
local STOPsprint = false


local function sprint( key )
for i = 1,20 do
if sprintmulti <= 20 and STOPsprint == false then
Character.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed + 0.7
sprintmulti = sprintmulti + 1
wait(0.05)
print(Character.Humanoid.WalkSpeed) 

else
--Already sprinting at max speed.
wait(0.05)
end
end
end

local function stopsprint( key )
STOPsprint = true
for i = 1,sprintmulti do
Character.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed - 0.7
sprintmulti = sprintmulti - 1
wait(0.05)

end
STOPsprint = false
end



local function onKeyDown( key )
if key == (" ")then jump()
elseif
key == ("0")then sprint()
else
print("Non action key is pressed", key)
end
end

local function onKeyUp( key )
if key == (" ")then stopjump()
elseif
key == ("0") then stopsprint()
else
print("Non action key is released", key)
end
end


mouse.KeyDown:connect(onKeyDown)
mouse.KeyUp:connect(onKeyUp)


0
tab. your. goddamn. script. qq NotSoNorm 777 — 9y

Answer this question