function MasterControl.Init(U)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(U)areControlsEnabled=true isJumpEnabled=true if U.ControlState.Current then U.ControlState.Current:Enable()end end function MasterControl.Disable(U)if U.ControlState.Current then U.ControlState.Current:Disable()end updateMovement()isJumping=false areControlsEnabled=false end function MasterControl.EnableJump(U)isJumpEnabled=true if areControlsEnabled and U.ControlState:IsTouchJumpModuleUsed()then U.TouchJumpModule:Enable()end end function MasterControl.DisableJump(U)isJumpEnabled=false if U.ControlState:IsTouchJumpModuleUsed()then U.TouchJumpModule:Disable()end end function MasterControl.AddToPlayerMovement(N,U)moveValue=Vector3.new(moveValue.X+U.X,moveValue.Y+U.Y,moveValue.Z+U.Z)end function MasterControl.GetMoveVector(U)return moveValue end function MasterControl.SetIsJumping(N,U)if not isJumpEnabled then return end isJumping=U local u=N:GetHumanoid()if u and not u.PlatformStand then u.Jump=isJumping end end function MasterControl.DoJump(U)if not isJumpEnabled then return end local N=U:GetHumanoid()if N then N.Jump=true end end function MasterControl.GetClickToMoveFailStateChanged(U)return clickToMoveFailStateChanged end return MasterControl
--
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

function MasterControl:GetClickToMoveFailStateChanged()
	return clickToMoveFailStateChanged
end

return MasterControl

