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

My sprint script does not function, and returns no output?

Asked by 4 years ago

Breakdown: This script is designed for my upcoming RPG, and I am having an error, I spawn with 16 speed like normal, and how I would like. But, when I press shift my speed does not increase, and if it does its not by the correct increments.

Script:

01repeat wait() until game.Loaded
02local Player = game.Players.LocalPlayer
03local Character = Player.Character
04local Humanoid = Character.Humanoid
05 
06local running = script.Running
07 
08local plr = game.Players.LocalPlayer
09local player = game.Players:FindFirstChild(plr.Name)
10repeat wait() until plr.Character
11local character = game.Workspace:FindFirstChild(player.Name)
12local mouse = plr:GetMouse()
13 
14mouse.KeyDown:connect(function (key)
15    key = string.lower(key)
View all 25 lines...
0
Pretty sure it's supposed to be string:byte not string.byte. Correct me if I am wrong. DesertusX 435 — 4y
0
I have a better solution to all of this. Easier to read instead of having all of those local variables. ifreakinlostmyacount 52 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

This is a sprint script I made a few weeks ago, it has animatios, but it broke the script if you consistantly spammed the shift button, so I got rid of them. Heres the localscript:

01game:GetService("UserInputService").InputBegan:connect(function(input)
02    if input.KeyCode == Enum.KeyCode.LeftShift then
03    game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 35
04 
05 
06    end
07        end)
08 
09game:GetService("UserInputService").InputEnded:Connect(function(input)
10    if input.KeyCode == Enum.KeyCode.LeftShift then
11    game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 17
12    end
13        end)

Make sure to put this in StarterPlayer.StarterCharacterScripts as a local script

Please upvote if this is the solution to your problem C:

0
You could maunually add new walkspeeds after a wait() so like WalkSpeed = 35 WalkSpeed = 36 etc. This can give more opertunity in velocity... ifreakinlostmyacount 52 — 4y
Ad

Answer this question