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

Removing player control code not working?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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
0
This prevents everything except movement. which is what I was shooting for. BSIncorporated 640 — 8y
0
Running and walking are the same so all you need to do to disable that is:humanoid:SetStateEnabled(Enum.HumanoidStateType.Walking, false) Thegrimdeathzombie 40 — 7y
Ad

Answer this question