Hello,
I’m trying to make a new control system, but when I move forward it keeps going forward not toward the look vector how can I fix this and does this go at the speed as the humanoid walk speed is set at?
What I have so far:
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local moveValue = 0
local function onMove(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
moveValue = 1
elseif inputState == Enum.UserInputState.End then
moveValue = 0
end
end
local function onAim()
if player.Character then
local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
local mouseLocation = Vector3.new(mouse.Hit.X, rootPart.Position.Y, mouse.Hit.Z)
rootPart.CFrame = CFrame.new(rootPart.Position, mouseLocation)
end
end
local function onUpdate()
if player.Character and player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid:Move(Vector3.new(0,0,moveValue), false)
end
end
RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
ContextActionService:BindAction("Aim", onAim, false, Enum.UserInputType.MouseMovement)
ContextActionService:BindAction("Move", onMove, true, Enum.KeyCode.W, Enum.KeyCode.Up, Enum.KeyCode.DPadUp)
Thank you in advance