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

how to change walk speed with a script?

Asked by
mewtify 26
4 years ago

hi,I’m very new to coding and I am trying to make it so the character doesn’t move during a specific scene. I wanted to know how I would simply make the walk speed 0, then make it back into the default (16 I believe?) using a script. I have looked online but I couldn’t find anything that was simple enough. would I use StarterPlayer since properties are in there for walk speed? I’m just pretty confused, thank you!

0
How have you been playing Roblox since 2013 and still don’t know how to code (no hate) lol just asking lol iivSnooxy 248 — 4y
2
haha I know right, I never really been into coding since it always “scared” me I guess? I know the basics and all, but I have most of the trouble when writing it out. actually most of my problems coding come from the scripts not running which was the case most of the time, but I want to make sure my code is right before testing everything for it not to work mewtify 26 — 4y
0
when you start playing roblox has no bearing on how good you are to code. coding isnt something everyone does, dont feel ashamed zadobyte 692 — 4y
0
do mqop3434 -64 — 4y

4 answers

Log in to vote
2
Answered by
uhi_o 417 Moderation Voter
4 years ago

You can use a LocalScript for this.

At a certain event you can

game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0

or you can also do this with a player added event.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(character)
        character.Humanoid.WalkSpeed = 0
    end)
end)
Ad
Log in to vote
1
Answered by
zadobyte 692 Moderation Voter
4 years ago
Edited 4 years ago
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
char:WaitForChild("Humanoid").Walkspeed = 0

I suggest you start learning coding though, so that you dont have to ask as many questions and so that you fully understand what's told to you.

Accept the answer that helps!

Log in to vote
0
Answered by
mqop3434 -64
4 years ago
Edited by raid6n 4 years ago
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(character)
            character.Humanoid.WalkSpeed = 0
        end)
    end)

Log in to vote
-1
Answered by
ghxstlvty 133
4 years ago

You can do this by making a script under workspace and pasting this into it:

function onPlayerEntered(newPlayer)
newPlayer.Character.Humanoid.WalkSpeed = 0
end
game.Players.ChildAdded:Connect(onPlayerEntered)

function onPlayerRespawned(newPlayer)
local Humanoid = newPlayer:findFirstChild("Humanoid")
if Humanoid ~= nil then
if game.Workspace:findFirstChild(Humanoid.Parent.Name) ~= nil then
Humanoid.WalkSpeed = 0
end
end
end
game.Workspace.ChildAdded:Connect(onPlayerRespawned)

This script ensures that if a player resets it still keeps the walk speed the same.

Answer this question