Roblox How To | Creating a Simple Shift to Sprint Script!
This is for those people who get free models for Shift To Sprint Scripts.
Step 1 - Making The Script
First of all, you want to make a new local Script inside of StarterPlayerScripts
which can be found by going to StarterPlayer
, Name it whatever you want!
Step 2 - Coding The Script
Next, we want to open the script. We need to define the character though and the player so that we can put up their walkspeed! to do that you need to put this:
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService") -- We do this so we can get the players inputs
local player = Players.LocalPlayer -- Gets the player from the local script, Local Player will be considered by its script location., so If it wasn't in a player this would not work
local character = player.CharacterAdded:Wait() -- Waiting until the Player's character gets added to
local Debounce = false -- a Debounce that you can optionally put.
local CooldownTimer1 = 5
after that, you would want to put:
UIS.InputBegan:Connect(function(input, GPE) -- Connecting to the input that got in, GPE = Game Processed Event and is if the game processed it and if the player is busy, like typing in the chat for an example
if input.KeyCode == Enum.KeyCode.LeftShift then -- Self Explanitory
if not Debounce then -- A Debounce if you don't want the player to sprint forever
Debounce = true
character.Humanoid.WalkSpeed = IntValue -- Set this to any number you want, or variable
wait(10) -- Set the number to anything
for i = 1, ( Whatever you added to the humanoids Walkspeed ) do -- for loop making it so that the player will slowly stop
wait(0.5)
character.Humanoid.WalkSpeed = character.Humanoid.WalkSpeed - i -- Subtracts the current walkspeed from i
end
character.Humanoid.WalkSpeed = 16
wait(CooldownTimer1) -- Waits the Debounce time for it to be able to use again
Debounce = false -- Makes it so that it can be used again
end
end
end)
And their you go! This is how to make a Simple Shift To Spring Script! Read all of the comments I made if you don’t understand the script!
Please consider liking this post and maybe sharing it to other who need it, It would make me happy considering I put lots of time and hard work into this!
Comments
Post a Comment