Speed Boosts

Make the player faster

by winner803

Author Avatar

Introduction

Do you want to make your player faster? You should make a speed boost. There are two types of speed boost:

  1. GUI Speed Boost
  2. Block Speed Boost The GUI speed boost is a window the player can buy from it a temperory or perminant speed boost. The Block Speed Boost is a block that the player clicks on it to be faster temperory. I will concentrate on the Block Speed Boost.

Create the speed boost part.

First, create a part in the workspace and in it a script. You can choose any scales, and it will be better to put a decal on it such as this one

img|80x45

If you want that photo, this is its URL (https://web.roblox.com/library/4783611726/Run).

Set the variables.

In the script, you will identify some variables. The variables are the speed boost part, the duration of the speed boost, and a variable called "active". I will tell you why we will make a variable named "active" later.

local SpeedBoost = script.Parent --[[The parent of this script is
the speed boost.]]
local duration = 10 -- you can change the number as you want.
local active = false

Make the function

Then, you should make the function that will make the player faster. I will name it "fast", and I will put a parameter called "leg" which is the leg that will touch it. I will also identify a variable in the function which is humanoid to identify whether humanoid(player) is touching or no.

local function fast(leg)
    local character = leg.Parent -- parent of leg is the player
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")
end

Why we need to identify humanoid although we identified the player? Because variable "character" is identified as the parent of parameter "leg", and leg is the part that will touch the speed boost. The ground is touching the speed boost, and its parent is the "workspace", so the speed boost will work on workspace. But, nothing contain "humanoid" except players and NPCs.

Making player faster with an If statement

Now, we will make an If statement, but before i till you what the If statement will contain, you should know now why i made the variable "active". In the If statement, I will put a condition which is active is equal false because if the player clicked many times on the speed boost an error in time will occurr, so I will make the player faster and active equal true, so if he touched the booster again, the condition will not be true. Then, after the time i will make the speed normal and will make active false, so he can click it again. Now, there will be two conditions for the If statement: humanoid touched and as i said active equal false. The statement should be like this.

if humanoid and active == false then
    humanoid.WalkSpeed = 50 --change the number as you want
    active = true 
    wait(duration)
    humanoid.WalkSpeed = 16 --the normal speed of the player
    active = false
end

Calling the function and making event

Finally, we will make a event that will start the function when the player touches the part!

SpeedBoost.Touched:connect(fast) --[[make sure there is no brackets 
after the name of the function.]]

At first, we have wrote the name of the part and a properity in it called Touched which check whether the part is touched or no. Second, if it is touched connect , or start, the function that is named fast.

The whole script

local SpeedBoost = script.Parent
local duration = 10 -- you can change the number as you want.
local active = false

local function fast(leg)
    local character = leg.Parent
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")


    if humanoid and active == false then
        humanoid.WalkSpeed = 50 --change the number as you want
        active = true 
        wait(duration)
        humanoid.WalkSpeed = 16 --the normal speed of the player
        active = false
    end
end

SpeedBoost.Touched:connect(fast) --[[make sure there is only one bracket 
after the name of the function.]]

TroubleShooting

Pay attention for all words capitalizations except the names of variables and functions. Make sure at the end when calling the function there is no brackets after the function name. There must be to "end" words: 1 for the if statement and other for the function.

Edit

Some people have encountered some problems when they take the script such as the script did not work. Sorry, I wrote some words and capitalizations wrong. I am so sorry, but i solved the problem and you can use the script!

Conclution

That all! Now, you can make speed boosters as you want.

View in-game to comment, award, and more!