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

Removing player control code not working?

So I recently needed a script for my game that removes a player's control over their player (changing the movement to be click-to-move)

Code:

for _, controller in pairs(game:GetService("ControllerService"):GetChildren()) do
	controller.Parent = nil
end

The code IS in a LocalScript in StarterGui

1 answer

You Cannot Delete Controller Service But You Can Override Them In PlayerStarterScripts here's an example (for a local script)

local function onCharacterAdded(character)
local humanoid = character:WaitForChild('Humanoid')	
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)	
humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.StrafingNoPhysics, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)
end

2 comments

0

This prevents everything except movement. which is what I was shooting for.

0

Running and walking are the same so all you need to do to disable that is:humanoid:SetStateEnabled(Enum.HumanoidStateType.Walking, false)

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