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

How to remove character control?

Asked by
emite1000 335 Moderation Voter
9 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
5
Answered by
2eggnog 981 Moderation Voter
9 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.
wait(5)
controller.Parent = controllerService --Gives control back.
0
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 — 9y
0
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 — 9y
Ad

Answer this question