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

Disable player movement if on a part?

Asked by 2 years ago

Hello, I want to make a block that disables player movement.

How would I go about this?

Thanks

1 answer

Log in to vote
1
Answered by 2 years ago

Inside the the part, add in a Script and type this

script.Parent.Touched:Connect(function(hit)

    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
            local humanoid = player.Character:WaitForChild("Humanoid")
            humanoid.WalkSpeed = 0
            -- add "humanoid.JumpPower = 0" if you want the player not to have jump height too.
        end
    end

end)
0
Do you know how to implement this into a local script also? Helloimpets 17 — 2y
0
@Helloimpets LocalScript usually wouldn't work because it would only apply to the client and not the entire server. I may be wrong though. PaleNoobs 37 — 2y
Ad

Answer this question