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!
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)
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!
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(character) character.Humanoid.WalkSpeed = 0 end) end)
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.