local TARGET_SPEED = 10
local w = false
local a = false
local s = false
function stopmove(input)
if input.KeyCode == Enum.KeyCode.W then
w = false
end
if input.KeyCode == Enum.KeyCode.A then
a = false
end
if input.KeyCode == Enum.KeyCode.S then
s = false
end
end
function forward(input)
if input.KeyCode == Enum.KeyCode.W then
w = true
repeat wait()
px,py,pz,xx,yx,zx,xy,yy,zy,xz,yz,zz = cam.CoordinateFrame:components()
char.player.forward.AngularVelocity = Vector3.new(-xx * TARGET_SPEED,0,zx * TARGET_SPEED)
print(input.KeyCode)
until w == false
char.player.forward.AngularVelocity = Vector3.new(0,0,0)
end
end
function back(input)
if input.KeyCode == Enum.KeyCode.S then
s = true
repeat wait()
px,py,pz,xx,yx,zx,xy,yy,zy,xz,yz,zz = cam.CoordinateFrame:components()
char.player.back.AngularVelocity = Vector3.new(xx * TARGET_SPEED,0,-zx * TARGET_SPEED)
print(input.KeyCode)
until s == false
char.player.back.AngularVelocity = Vector3.new(0,0,0)
end
end
function left(input)
if input.KeyCode == Enum.KeyCode.A then
a = true
repeat wait()
px,py,pz,xx,yx,zx,xy,yy,zy,xz,yz,zz = cam.CoordinateFrame:components()
char.player.left.AngularVelocity = Vector3.new(-xz * TARGET_SPEED,0,xx * TARGET_SPEED)
print(input.KeyCode)
until a == false
char.player.left.AngularVelocity = Vector3.new(0,0,0)
end
end
userinput.InputBegan:Connect(left)
userinput.InputEnded:Connect(stopmove)
userinput.InputBegan:Connect(forward)
userinput.InputBegan:Connect(back)
when I play test this it registers the input, but only when I press w.
I have already tried combining the functions into one but no luck.
I’m really unsure what to do here
