How do i improve this custom character movement?

Hello i wrote a custom character movement from last post made by me, but its kinda bad, and i dont know what else to do to make it perfect. Could anyone help?

local Char = script.Parent
local Hum = Char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local Velocity = Instance.new("BodyAngularVelocity",Char.LowerTorso)
Velocity.AngularVelocity = Vector3.new(0,0,0)
local SpinnedOn

UIS.InputBegan:Connect(function(Key, Typing)
	if not Typing and Key.KeyCode == Enum.KeyCode.A then
		Velocity.AngularVelocity = Vector3.new(0,5,0)
		wait(0.5)
		Velocity.AngularVelocity = Vector3.new(0,0,0)
		SpinnedOn = "A"
	elseif not Typing and Key.KeyCode == Enum.KeyCode.D then
		Velocity.AngularVelocity = Vector3.new(0,-5,0)
		wait(0.5)
		Velocity.AngularVelocity = Vector3.new(0,0,0)
		SpinnedOn = "D"
	elseif not Typing and Key.KeyCode == Enum.KeyCode.S then
		Velocity.AngularVelocity = Vector3.new(0,-2,0)
		wait(0.5)
		Velocity.AngularVelocity = Vector3.new(0,0,0)
		SpinnedOn = "S"
	elseif not Typing and Key.KeyCode == Enum.KeyCode.W then
		if SpinnedOn == "D" or SpinnedOn == "A" then
			Velocity.AngularVelocity = Vector3.new(0,5,0)
			wait(0.5)
			Velocity.AngularVelocity = Vector3.new(0,0,0)
			SpinnedOn = "W"
		end
	end
end)
  1. goes to code review probs

This is basically the same as your code, but it definitely doesn’t work the way you want it to.

local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local Character = script.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local BodyAngularVelocity = Instance.new("BodyAngularVelocity", Character.LowerTorso)
local keys = {A=false,D=false,S=false,W=false}

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if not gameProcessed and keys[input.KeyCode.Name]~=nil then
		keys[input.KeyCode.Name] = true
	end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
	if not gameProcessed and keys[input.KeyCode.Name]~=nil then
		keys[input.KeyCode.Name] = false
	end
end)
RunService.RenderStepped:Connect(function()
	BodyAngularVelocity.AngularVelocity = Vector3.new(
		0,
		(keys.S and -2) or (keys.W and 5) or (keys.A and 5) + (keys.D and -5),
		0
	)
end)

That code doesn’t work either, i’ll guess i will have to give up on this one