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