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

How can I change the walk speed of the player?

Asked by 6 years ago
local LocalPlayer = game.Players.LocalPlayer
LocalPlayer.Character.WalkSpeed = game.ReplicatedStorage.Points.Value + 3

'Attempt to index local 'LocalPlayer' (a nil value)'

0
I suggest you use a Script, if you are using FilteringEnabled, LocalScripts are not supposed to be doing this. dionant 23 — 6y
0
I am using a script in server script service jalbraek 29 — 6y
0
ServerScriptService can't access "LocalPlayer", that can only be accessed by LocalScripts gitrog 326 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

I don't know how you want to increase the player's speed, for example it happens when you touch a brick or a key bind. Since you're using a server script, you're trying to access the LocalPlayer, but that's only available through local scripts, not server. Either you can put your original code in a local script, or you can do this:

game.Players.PlayerAdded:Connect(function(plr)--This happens whenever a player joins

    local char = plr.Character or plr.CharacterAdded:Wait()--Gets player's character
    local hum = char.Humanoid
    hum.WalkSpeed = game.ReplicatedStorage.Points.Value + 3

end)

This code goes in a normal script. Put this script in ServerScriptService. I also noticed you're trying to set the WalkSpeed from the character. It's the character's humanoid that you do this to, not the actual character.

Ad
Log in to vote
0
Answered by
danglt 185
6 years ago
Edited 6 years ago
local localPlayer = game.Players.LocalPlayer
localPlayer.Character.Humanoid.WalkSpeed = game.ReplicatedStorage.Points.Value + 3

You were using the local as "LocalPlayer"

so it diden't know what to use. , also you need to use a Humanoid

0
Also are you using it in a LocalScript? danglt 185 — 6y
0
This didn't work same error message jalbraek 29 — 6y

Answer this question