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

Help With Restricting Player Movement For A Cutscene?

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

✓ Accepted answer

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()

6 comments

0

I can't, because the player must move during the cutscene.

0

However, thank you for taking the time to answer.

0

I updated my answer, see if that works.

0

You would just have to change to LocalPlayer to whichever player you want.

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.

0

YES! I LOOKED IT UP AND FOUND MORE CODE TO ACCUSTOM YOUR SOLUTION! THANK YOU!

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