function MasterControl.Init(Q)RunService:BindToRenderStep("\077\097\115\116\101\114\067\111\110\116\114\111\108\083\116\101\112",Enum.RenderPriority.Input.Value,updateMovement)end function MasterControl.Enable(Q)areControlsEnabled=true isJumpEnabled=true if Q.ControlState.Current then Q.ControlState.Current:Enable()end end function MasterControl.Disable(Q)if Q.ControlState.Current then Q.ControlState.Current:Disable()end updateMovement()isJumping=false areControlsEnabled=false end function MasterControl.EnableJump(Q)isJumpEnabled=true if areControlsEnabled and Q.ControlState:IsTouchJumpModuleUsed()then Q.TouchJumpModule:Enable()end end function MasterControl.DisableJump(Q)isJumpEnabled=false if Q.ControlState:IsTouchJumpModuleUsed()then Q.TouchJumpModule:Disable()end end function MasterControl.AddToPlayerMovement(B,Q)moveValue=Vector3.new(moveValue.X+Q.X,moveValue.Y+Q.Y,moveValue.Z+Q.Z)end function MasterControl.GetMoveVector(Q)return moveValue end function MasterControl.SetIsJumping(B,Q)if not isJumpEnabled then return end isJumping=Q local Z=B:GetHumanoid()if Z and not Z.PlatformStand then Z.Jump=isJumping end end function MasterControl.DoJump(Q)if not isJumpEnabled then return end local B=Q:GetHumanoid()if B then B.Jump=true end end return MasterControl
--[[ Public API ]]
--
function MasterControl:Init()
	RunService:BindToRenderStep("MasterControlStep", Enum.RenderPriority.Input.Value, updateMovement)
end

function MasterControl:Enable()
	areControlsEnabled = true
	isJumpEnabled = true

	if self.ControlState.Current then
		self.ControlState.Current:Enable()
	end
end

function MasterControl:Disable()
	if self.ControlState.Current then
		self.ControlState.Current:Disable()
	end

	--After current control state is disabled, moveValue has been set to zero,
	--Call updateMovement one last time to make sure this propagates to the engine -
	--Otherwise if disabled while humanoid is moving, humanoid won't stop moving.
	updateMovement()

	isJumping = false
	areControlsEnabled = false
end

function MasterControl:EnableJump()
	isJumpEnabled = true
	if areControlsEnabled and self.ControlState:IsTouchJumpModuleUsed() then
		self.TouchJumpModule:Enable()
	end
end

function MasterControl:DisableJump()
	isJumpEnabled = false
	if self.ControlState:IsTouchJumpModuleUsed() then
		self.TouchJumpModule:Disable()
	end
end

function MasterControl:AddToPlayerMovement(playerMoveVector)
	moveValue = Vector3.new(
		moveValue.X + playerMoveVector.X,
		moveValue.Y + playerMoveVector.Y,
		moveValue.Z + playerMoveVector.Z
	)
end

function MasterControl:GetMoveVector()
	return moveValue
end

function MasterControl:SetIsJumping(jumping)
	if not isJumpEnabled then
		return
	end
	isJumping = jumping
	local humanoid = self:GetHumanoid()
	if humanoid and not humanoid.PlatformStand then
		humanoid.Jump = isJumping
	end
end

function MasterControl:DoJump()
	if not isJumpEnabled then
		return
	end
	local humanoid = self:GetHumanoid()
	if humanoid then
		humanoid.Jump = true
	end
end

return MasterControl
