function MasterControl.GetHumanoid(c)if LocalCharacter then if CachedHumanoid then return CachedHumanoid else CachedHumanoid=LocalCharacter:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")return CachedHumanoid end end end VRService.Changed:connect(function(c)if c=="\086\082\069\110\097\098\108\101\100"then VREnabled=VRService.VREnabled end end)local c=nil local A=nil local function p(p)if c then c:disconnect()end if A then A:disconnect()end LocalCharacter=p CachedHumanoid=LocalCharacter:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")c=p.AncestryChanged:connect(function()if p.Parent==nil then LocalCharacter=nil else LocalCharacter=p end end)A=p.ChildRemoved:connect(function(c)if c==CachedHumanoid then CachedHumanoid=nil end end)end if LocalCharacter then p(LocalCharacter)end LocalPlayer.CharacterAdded:connect(p)local l=MasterControl.GetHumanoid local u=LocalPlayer.Move local I=VRService.GetUserCFrame local Z=function()if not areControlsEnabled then return end local c=l()if not c then return end if isJumpEnabled and(isJumping and not c.PlatformStand)then local A=c:GetState()if A~=STATE_JUMPING and(A~=STATE_FREEFALL and A~=STATE_LANDED)then c.Jump=isJumping end end local A=moveValue if VREnabled and workspace.CurrentCamera.HeadLocked then local c=I(VRService,Enum.UserCFrame.Head)local p=(Vector3.new(c.lookVector.X,0,c.lookVector.Z)).unit local l=CFrame.new(ZERO_VECTOR3,p)A=l:vectorToWorldSpace(A)end u(LocalPlayer,A,true)end
--[[ Local Functions ]]
--
function MasterControl:GetHumanoid()
	if LocalCharacter then
		if CachedHumanoid then
			return CachedHumanoid
		else
			CachedHumanoid = LocalCharacter:FindFirstChildOfClass("Humanoid")
			return CachedHumanoid
		end
	end
end

VRService.Changed:connect(function(prop)
	if prop == "VREnabled" then
		VREnabled = VRService.VREnabled
	end
end)

local characterAncestryChangedConn = nil
local characterChildRemovedConn = nil
local function characterAdded(character)
	if characterAncestryChangedConn then
		characterAncestryChangedConn:disconnect()
	end

	if characterChildRemovedConn then
		characterChildRemovedConn:disconnect()
	end

	LocalCharacter = character
	CachedHumanoid = LocalCharacter:FindFirstChildOfClass("Humanoid")
	characterAncestryChangedConn = character.AncestryChanged:connect(function()
		if character.Parent == nil then
			LocalCharacter = nil
		else
			LocalCharacter = character
		end
	end)

	characterChildRemovedConn = character.ChildRemoved:connect(function(child)
		if child == CachedHumanoid then
			CachedHumanoid = nil
		end
	end)
end

if LocalCharacter then
	characterAdded(LocalCharacter)
end
LocalPlayer.CharacterAdded:connect(characterAdded)

local getHumanoid = MasterControl.GetHumanoid
local moveFunc = LocalPlayer.Move
local getUserCFrame = VRService.GetUserCFrame
local updateMovement = function()
	if not areControlsEnabled then
		return
	end

	local humanoid = getHumanoid()
	if not humanoid then
		return
	end

	if isJumpEnabled and isJumping and not humanoid.PlatformStand then
		local state = humanoid:GetState()
		if state ~= STATE_JUMPING and state ~= STATE_FREEFALL and state ~= STATE_LANDED then
			humanoid.Jump = isJumping
		end
	end

	local adjustedMoveValue = moveValue
	if VREnabled and workspace.CurrentCamera.HeadLocked then
		local vrFrame = getUserCFrame(VRService, Enum.UserCFrame.Head)
		local lookVector = Vector3.new(vrFrame.lookVector.X, 0, vrFrame.lookVector.Z).unit
		local rotation = CFrame.new(ZERO_VECTOR3, lookVector)
		adjustedMoveValue = rotation:vectorToWorldSpace(adjustedMoveValue)
	end

	moveFunc(LocalPlayer, adjustedMoveValue, true)
end
