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

How can i make the players speed equal to the Speed leaderstat? [closed]

Asked by 4 years ago

I'm pretty new to scripting, and i'm wondering how to make the players speed equal to the leaderstats. I have made the leaderstat for the players speed and i have made it so it increases when a player uses the tool, but i'm lost on how i can the player's speed equal to the Speed leaderstat. Can anybody help?

0
code? matiss112233 258 — 4y
0
Also, make sure you add a wait when using loops or it will never get to the second line of code. Because the code will essentially, check infinite times JesseSong 3916 — 4y

Closed as Not Constructive by JesseSong, EmbeddedHorror, Fifkee, Leamir, cailir, and User#29913

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

In a local script you can do something like this (I am not able to check right now so there may be some bugs):

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local leaderstats = player.leaderstats
local playerSpeed = leaderstats.speed

function FunctionToBeCalled()
    character.Humanoid.WalkSpeed = playerSpeed

end

Obviously as you have shown no code, I cant help you more specifically, but this is in general. I would recommend getting more familiar with roblox studio and its language before trying anything too advanced.

0
Its best to use a loop since it will check every time and not break the script . JesseSong 3916 — 4y
1
Wrong. Loops definitely aren't optimal for a purpose like this. He was hinting to use the Changed connection on the leaderstats value. Fifkee 2017 — 4y
Ad