Hey.
I am making a custom character movement system. I made it work but its a bit bugged so I am here to get help.
Heres my script (localscript in starterplrscripts):
local movements = {
["forw"] = Enum.KeyCode.W,
["left"] = Enum.KeyCode.A,
["back"] = Enum.KeyCode.S,
["right"] = Enum.KeyCode.D,
}
local inputs = setmetatable({}, {
__index = function(t, k)
return game:GetService("UserInputService"):IsKeyDown(movements[k]) and 1 or 0
end
})
local player = game:GetService("Players").LocalPlayer
player.CharacterAdded:Wait()
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
game:GetService("RunService").RenderStepped:Connect(function()
local movez = inputs.forw - inputs.back
local movex = inputs.left - inputs.right
humanoid:Move(Vector3.new(0, 0, -movez - 5) + Vector3.new(-movex, 0, 0), true)
end)
In the script you keep moving all the time, even if you don’t press wasd. Altho left and right works u keep moving forward, w and s dont move u. im ok with the player moving all the time, id like to know how can i reduce the speed at which they keep moving. I had to do -movez - 5
as i dont want them to turn super fast as my game is high speed based. this prevents them from turning super fast but also makes them move all the time, which i dont know how to prevent. thanks