Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make person's walkspeed 0?

I am making a baseball game and ran into a problem I can't fix. So basically, when someone enters the batters box, I want them to have 0 walkspeed. I know that it has to do with the humanoid, but problem is I just dont know how to implement it and I've tried everything. Help would be appreciated

-- Variables/Other
local IsBatting = false
local RH = game.Workspace.PlayerParts.RH
local LH = game.Workspace.PlayerParts.LH
-- Camera Stuff
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local BatterCamera = game.Workspace.MouseIgnores.BatterCamera
-- Character/Player Stuff
local Player = game.Players.LocalPlayer

-- Functions

function TweenCamera()
	Camera.CameraType = Enum.CameraType.Scriptable
	local TI = TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out, 0) -- Duration, Style, Direction, How many times repeated
	local Goal = {CFrame = BatterCamera.CFrame, FieldOfView = 60}
	local Animation = TweenService:Create(Camera, TI, Goal)
	Animation:Play()
end

function StartAtBat(WhichSide)
	if IsBatting then -- Checks if there is already a person batting
		return
else
	IsBatting = true
end
	TweenCamera()
end

RH.Touched:Connect(function()
	StartAtBat(RH)
end)

LH.Touched:Connect(function()
	StartAtBat(LH)
end)

5 comments

0

Have you tried game.Players.LocalPlayer.Humanoid.WalkSpeed = 0?

0

Yes, it says that 'Humanoid is not a valid member of Player'

1

oh! My mistake! I meant game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0

0

It works, thanks very much

0

np. Accept my answer.

1 answer

✓ Accepted answer

All you need to do is change the player variable.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.