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

How to make person's walkspeed 0?

Asked by 4 years ago

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)
0
Have you tried game.Players.LocalPlayer.Humanoid.WalkSpeed = 0? hihowareya115 53 — 4y
0
Yes, it says that 'Humanoid is not a valid member of Player' FriendBandsX 14 — 4y
1
oh! My mistake! I meant game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 hihowareya115 53 — 4y
0
It works, thanks very much FriendBandsX 14 — 4y
0
np. Accept my answer. hihowareya115 53 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

All you need to do is change the player variable.

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

Answer this question