Rotate Part to moving direction added the script forgot sorry

  1. What do you want to achieve? Keep it simple and clear!
    I am making a non humanoid character rig for my rpg game. (just for reasons)
    and i am done with the movement direction left,right,forward,backward and diagonal if 2 directions are combined

i want to make the (Root) part rotate to the direction it is moving, i thought this is pretty simple but i wasted a couple hours already and i don’t seem to be able to wrap my brain arround on what i am missing i also tried bodygyro but no success if u/i can make it look to the direction it is going (horizontal and diagonal) then its solved

this how it looks without the looking direction (basicly a bayblade XD)
https://i.gyazo.com/0550d3f57c6dacacec015a16fe704c85.mp4

the model is in StarterPlayer
and the script (Animate) is in StarterCharacterScripts

uncopylocked place or to test it out
https://www.roblox.com/games/5839734018/Placeholder-Test-1

hope sombody can help fix it thx for all reading and trying :wink:
the script

local character = script.Parent
local root = character:WaitForChild("Root")
local camera = workspace.CurrentCamera
local Run = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
camera.CameraType = Enum.CameraType.Watch
camera.CameraSubject = character:WaitForChild("Cam")
local walkspeed = 20



local bodyVelocity = root:WaitForChild("BodyVelocity")

lastPrint = ""
function printer(msg)
	if msg ~= lastPrint then
		lastPrint = msg
		print(msg)
	end
end




local function OnChanged()
	wait()
	local UserInputService = game:GetService("UserInputService")
	local left = UserInputService:IsKeyDown(Enum.KeyCode.A)
	local right = UserInputService:IsKeyDown(Enum.KeyCode.D)
	local forward = UserInputService:IsKeyDown(Enum.KeyCode.W)
	local backward = UserInputService:IsKeyDown(Enum.KeyCode.S)
	--local x,y,z = camera.CFrame:ToEulerAnglesXYZ()
	--movement 1 axis horizontal
	if left and not right and not forward and not backward then
		--single left
		printer("left")
		bodyVelocity.Velocity = (Vector3.new(-camera.CFrame.RightVector.X,0,-camera.CFrame.RightVector.Z)* walkspeed)
		--character:SetPrimaryPartCFrame(camera.CFrame)
		--character:SetPrimaryPartCFrame(CFrame.new(root.Position,-(Vector3.new(camera.CFrame.RightVector.X,0,camera.CFrame.RightVector.Z))))
	elseif right and not left and not forward and not backward then
		--single right
		printer("right")
		bodyVelocity.Velocity = Vector3.new(camera.CFrame.RightVector.X,0,camera.CFrame.RightVector.Z)* walkspeed
		--character:SetPrimaryPartCFrame(CFrame.new(root.Position,Vector3.new(camera.CFrame.RightVector.X,0,camera.CFrame.RightVector.Z)))
	elseif forward and not backward and not left and not right then
		--single forward
		printer("forward")
		bodyVelocity.Velocity = Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z)* walkspeed
		--character:SetPrimaryPartCFrame(CFrame.new(root.Position,Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z)))
	elseif backward and not forward and not left and not right then
		--single backwards
		printer("backward")
		bodyVelocity.Velocity = -(Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z)* walkspeed)
		--character:SetPrimaryPartCFrame(CFrame.new(root.Position,-(Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z))))
	--movement 2 axis diagonal
	--frontleft \
	elseif left and forward and not right and not backward then
		printer("frontleft")
		bodyVelocity.Velocity = -(Vector3.new(camera.CFrame.RightVector.X,0,camera.CFrame.RightVector.Z)* 20) + Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z)* 20
	--backleft /
	elseif left and backward and not right and not forward then
		printer("backleft")
		bodyVelocity.Velocity = -(Vector3.new(camera.CFrame.RightVector.X,0,camera.CFrame.RightVector.Z)* walkspeed) +-(Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z)* walkspeed)
	--frontright /
	elseif right and forward and not left and not backward then
		printer("frontright")
		bodyVelocity.Velocity = Vector3.new(camera.CFrame.RightVector.X,0,camera.CFrame.RightVector.Z)* walkspeed + Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z)* walkspeed
	--backright \
	elseif right and backward and not left and not forward then
		printer("backright")
		bodyVelocity.Velocity = Vector3.new(camera.CFrame.RightVector.X,0,camera.CFrame.RightVector.Z)* walkspeed + -(Vector3.new(camera.CFrame.LookVector.X,0,camera.CFrame.LookVector.Z)* walkspeed)
	else
		printer("standing")
		bodyVelocity.Velocity = Vector3.new(0, 0, 0)
	end
end
Run.RenderStepped:Connect(OnChanged)