Code useless in other platforms

Basically, I have some old code that has been given to me by someone else on this forum long ago, and I bumped in an issue. However, they seem to be less active and haven’t answered my DM.

The Issue: This code freezes people and doesn’t allow the character to move (Permanent effect inteded, part of the game), only jump. However, I tested for the first time outside of Studio, on a tablet, and it’s possible to use the built-in controls to move. I suppose this also applies to console…

local ContextActionService = game:GetService("ContextActionService")
local ACTION = "freezeMovement"

local Disable = {
	Enum.PlayerActions.CharacterLeft,
	Enum.PlayerActions.CharacterRight,
	Enum.PlayerActions.CharacterForward,
	Enum.PlayerActions.CharacterBackward,
}


-- Disable movement
local function disableMovement()
	ContextActionService:BindAction(
		ACTION,
		function() 
			return Enum.ContextActionResult.Sink
		end,
		false,
		unpack(Disable)
	)
end

-- Enable movement
local function enableMovement()
	ContextActionService:UnbindAction(ACTION)
end


local events = game:GetService("ReplicatedStorage").Events
events.Start.OnClientEvent:Connect(disableMovement)
events.End.OnClientEvent:Connect(enableMovement)

This is on a local script in StarterPlayerScripts

Can’t you just set the WalkSpeed to 0 and leave JumpHeight unaffected under the humanoid?

2 Likes

I tried changing the Game Settings. Set Walkspeed to 0, left JumpHeight as it is and deleted the script. Does not work.

IMPORTANT EDIT: Nevermind, I had a StarterCharacter and it replaced the WalkSpeed with the one set in the Humanoid. I just changed it to 0, works perfectly on Studio. I still have to test in Mobile.

1 Like

How often do you fire the events here?

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