local G={[Enum.KeyCode.W]=Vector3.new(0,0,-1),[Enum.KeyCode.A]=Vector3.new(-1,0,0),[Enum.KeyCode.S]=Vector3.new(0,0,1);[Enum.KeyCode.D]=Vector3.new(1,0,0)}local l local A={}function A.GetInput(l)local A=Vector3.new()local X local H=UserInputService:GetKeysPressed()for l,H in pairs(H)do if G[H.KeyCode]then A+=G[H.KeyCode]elseif H.KeyCode==Enum.KeyCode.Space then X=true end end local Z=Camera.CFrame local p,O,t=Z:ToOrientation()local n=CFrame.Angles(0,O,t)local f=n:VectorToWorldSpace(A)RobloxianController:TellControl(f,X,n.LookVector)end function A.Deactivate(G)l:Destroy()end function A.Activate(G)l._InputCon=RunService.RenderStepped:Connect(function()G:GetInput()end)end function A.Start(G)RobloxianController=G.Controllers.RobloxianController l=G.Shared.Maid.new()end function A.Init(G) end return A

local MovementMap = {
    [Enum.KeyCode.W] = Vector3.new(0, 0, -1);
    [Enum.KeyCode.A] = Vector3.new(-1, 0, 0);
    [Enum.KeyCode.S] = Vector3.new(0, 0, 1);
    [Enum.KeyCode.D] = Vector3.new(1, 0, 0)
}

local Maid

local MovementController = {}

function MovementController:GetInput()
    local totalVector = Vector3.new()
    local isJump 

    local allKeys = UserInputService:GetKeysPressed()

    for _, key in pairs(allKeys) do 
        if (MovementMap[key.KeyCode]) then 
            totalVector += MovementMap[key.KeyCode]
        elseif (key.KeyCode == Enum.KeyCode.Space) then 
            isJump = true
        end
    end

    local CameraCF = Camera.CFrame
    local X, Y, Z = CameraCF:ToOrientation()
    local newCF = CFrame.Angles(0, Y, Z)
    local FinalVector = newCF:VectorToWorldSpace(totalVector)

    RobloxianController:TellControl(FinalVector, isJump, newCF.LookVector)
end

function MovementController:Deactivate()
    Maid:Destroy()
end

function MovementController:Activate()
    Maid._InputCon = RunService.RenderStepped:Connect(function()
        self:GetInput()
    end)
end

function MovementController:Start()
    RobloxianController = self.Controllers.RobloxianController
    Maid = self.Shared.Maid.new()
end

function MovementController:Init()
	
end

return MovementController
