Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

2 comments

0

code?

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

1 answer

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.

2 comments

0

Its best to use a loop since it will check every time and not break the script .

1

Wrong. Loops definitely aren't optimal for a purpose like this. He was hinting to use the Changed connection on the leaderstats value.

This discussion is preserved as it was. New answers, comments, and votes are closed.