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

Help With Restricting Player Movement For A Cutscene?

Asked by
Nckripted 580 Moderation Voter
4 years ago

Currently I am making a Piggy-based game with some twists with another user. Recently, we are done with the main basics (keys, doors, menu, etc.) and I have decided to start on the cutscene. However, I don't want player movement, but I can't set their walk speed to 0 because they will be moving. I have heard that ContextActionService is a good way to begin, but I can't find anything that currently works. Here is the module I am using so far:

local module = {}

local replicatedStorage = game:GetService("ReplicatedStorage")
local restrictMovement = replicatedStorage:WaitForChild("RestrictMovement")
local allowMovement = replicatedStorage:WaitForChild("AllowMovement")
--ContextActionService can only be used on the client from what I've heard.

function module:RestrictPlayerMovement()
    restrictMovement:FireAllClients()
end

function module:AllowPlayerMovement()
    allowMovement:FireAllClients()
end

The local script looks like this:

local replicatedStorage = game:GetService("ReplicatedStorage")
local restrictMovement = replicatedStorage:WaitForChild("RestrictMovement")
local allowMovement = replicatedStorage:WaitForChild("AllowMovement")

restrictMovement.OnClientEvent:Connect(function()
    --Don't know what to put here
end)

allowMovement.OnClientEvent:Connect(function()
    --Don't know what to put here
end)

The functions are empty because I have no clue on what to do here. If anyone can help me or has a different way of doing this, help will be greatly appreciated.

Thanks!

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

That has a very simple solution. You just want to anchor the players HumanoidRootPart and bam, they can't move.

player.Character.HumanoidRootPart.Anchored = true -- makes unable to move
player.Character.HumanoidRootPart.Anchored = false -- makes able to move

In the 'player' part you just want to put whichever player you want. If you want all players though, you can just use a for loop.


Update: Try using this then:

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()
0
I can't, because the player must move during the cutscene. Nckripted 580 — 4y
0
However, thank you for taking the time to answer. Nckripted 580 — 4y
0
I updated my answer, see if that works. YAYAYGPPR 82 — 4y
0
You would just have to change to LocalPlayer to whichever player you want. YAYAYGPPR 82 — 4y
View all comments (2 more)
0
This doesn't work, but I will look more into your method. If this method ends up working out, I will mark this as correct. Nckripted 580 — 4y
0
YES! I LOOKED IT UP AND FOUND MORE CODE TO ACCUSTOM YOUR SOLUTION! THANK YOU! Nckripted 580 — 4y
Ad

Answer this question