ContextActionService not working at all

I’m currently working on an unicycle vehicle and I need all player controls disabled. The function that disables it was working fine until a few hours ago, until it randomly decided to stop working without making any changes to the script or anything else. I tried to recreate this and disabled all scripts and added a script to test with the following in it:

local function Setup()

	require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

	game:GetService("ContextActionService"):UnbindAction("jumpAction")
	game:GetService("ContextActionService"):UnbindAction("moveForwardAction")
	game:GetService("ContextActionService"):UnbindAction("moveBackwardAction")
	game:GetService("ContextActionService"):UnbindAction("moveLeftAction")
	game:GetService("ContextActionService"):UnbindAction("moveRightAction")

end

Setup()

…and sure enough it was not working. What should I do?

Why dont you use a variable for ContextActionService

This is just a test script, making it a variable won’t slove the problem.

Remove the prints, and the controls Enable, its only there for demonstration, also move the variables above the function

local function Setup()
	print("yo")

	local ControlScript = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = ControlScript:GetControls()
	Controls:Enable() -- enable the controls whenever you want
	Controls:Disable() -- disable the controls whenever you want

	game:GetService("ContextActionService"):UnbindAction("jumpAction")
	game:GetService("ContextActionService"):UnbindAction("moveForwardAction")
	game:GetService("ContextActionService"):UnbindAction("moveBackwardAction")
	game:GetService("ContextActionService"):UnbindAction("moveLeftAction")
	game:GetService("ContextActionService"):UnbindAction("moveRightAction")
	print("worked")
end

Setup()
print("called")

Just tried it on a default baseplate and it still dosen’t work, there are no errors or warnings.

what script did you place ? where did you place it?

A LocalScript in StarterCharacterScripts

uh, usually it works since it works for me

Did you change the code like I said?

Yep, it worked for me aswell until a few hours ago. May this be linked to recent roblox server problems?

Yes, I changed it like you said

I else got no idea then, i changed one thing with an if statement so try using that

local ControlScript = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = ControlScript:GetControls()
local player = game.Players.LocalPlayer
local ContextActionService = game:GetService("ContextActionService")

local function Setup()
	if player then
		print("yo")
		Controls:Disable() -- disable the controls whenever you want

		ContextActionService:UnbindAction("jumpAction")
		ContextActionService:UnbindAction("moveForwardAction")
		ContextActionService:UnbindAction("moveBackwardAction")
		ContextActionService:UnbindAction("moveLeftAction")
		ContextActionService:UnbindAction("moveRightAction")
		print("worked")
	end
end

Setup()

Yes, that works now, however after I tested yours I retested my original script and now works fine. Pretty wierd stuff

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.