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

How do I make a leaderstat be a player's walkspeed?

Asked by 5 years ago

Here is where I defined player:

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

This is my script to create the leaderstat:

    local speed = Instance.new("IntValue")
    speed.Value = walkspeed
    speed.Parent = leaderStats
    speed.Name = "Speed"

I just want to make a variable called walkspeed now but how do I make it equal the player's walkspeed?

0
speed.Value = player.Character.Humanoid.WalkSpeed GoldAngelInDisguise 297 — 5y
0
do like humanoid.WalkSpeed = speed.Value WillBe_Stoped 71 — 5y

1 answer

Log in to vote
-1
Answered by
ksony 54
5 years ago
Edited 5 years ago

local speed = Instance.new("IntValue") speed.Value = player.Character.Humanoid.WalkSpeed speed.Parent = leaderStats speed.Name = "Speed"
0
13:36:57.858 - Workspace.Main:79: attempt to index field 'Character' (a nil value) LukasESimpson 0 — 5y
0
Try speed.Value = player:WaitForChild("Character").Humanoid.WalkSpeed Rheines 661 — 5y
0
No error shows up but it won't work LukasESimpson 0 — 5y
0
If character is nil, this can failure yHasteeD 1819 — 5y
View all comments (4 more)
0
character might have not loaded yet, repeat wait() until player.Character should fix this GoldAngelInDisguise 297 — 5y
0
repeat wait until character is not a good way yHasteeD 1819 — 5y
0
then what is the best way to do this? GoldAngelInDisguise 297 — 5y
0
player.CharacterAdded:Wait() or player.CharacterAdded:Connect(function() ... end) the CharacterAdded:Wait() only works 1 attempt yHasteeD 1819 — 5y
Ad

Answer this question