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

How do i link leaderstat speed?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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

0
onChanged is not defined and i dont know what to define it as Gameplayer365247v2 1055 — 5y
0
You have to make the function.. smh andyad13 74 — 5y
0
Did you put in the function onChanged? andyad13 74 — 5y
0
How did you manage to write this script but not understand my answer? No offense. andyad13 74 — 5y
0
Incorrect code mate. Harry_TheKing1 325 — 3y
Ad

Answer this question