Log in to vote

How to remove character control?

Asked by
emite1000 335 Moderation Voter
7 years ago

How do you make it so that a player loses control of their character? As in, when they press the arrow keys they do not move? I thought that what gave Players control was the HumanoidRootPart, but deleting it just made my character sink through the ground, so now I'm stumped.

(what I'm really trying to accomplish is how to make it so that the Player can't move their character around, and this was the only way I could think of).

1 answer

Log in to vote
Answered by
2eggnog 981 Moderation Voter
7 years ago

Every player has a Controller object in the ControllerService. Removing that object will prevent the player from controlling their character, and putting it back gives them control of their character again.

Here is an example from the wiki. (This is done from a local script.)

local controllerService = game:GetService("ControllerService")
local controller = controllerService:GetChildren()[1]
controller.Parent = nil --Removes control of the character.
controller.Parent = controllerService --Gives control back.
Does each player have their own Controller and ControllerService, or will parenting the Controller somewhere else make every player on the server lose control? emite1000 335 — 7y
Each player has their own controller. However, it's only accessible locally. You cannot remove a player's control from a server script. 2eggnog 981 — 7y

Answer this question