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

How do i link leaderstat speed?

how do i link the speed value in the leaderstat to the local player walkspeed

    local dataStores = game:GetService("DataStoreService"):GetDataStore("Speed")

local deafaultSpeed = 0

local playerLeft = 0

  

game.Players.PlayerAdded:Connect(function(player)

local PlayerGui = player:WaitForChild('PlayerGui')

playerLeft = playerLeft + 1

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

leaderstats.Parent = player

wait(1)

local speed = Instance.new("IntValue")

speed.Name = "Speed"

speed.Value = game.StarterGui.ScreenGui.speed.Text

speed.Parent = leaderstats

1 answer

Try this out mate

function onChanged()
player.Character:WaitForChild("Humanoid").WalkSpeed = speed
end
speed.Changed:Connect(onChanged)

The onChanged function sets the walkspeed to the speed value and the function fires every time speed has changed so it updates whenever you change the speed value. Hope this helps mate

5 comments

0

onChanged is not defined and i dont know what to define it as

0

You have to make the function.. smh

0

Did you put in the function onChanged?

0

How did you manage to write this script but not understand my answer? No offense.

0

Incorrect code mate.

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