Ok, i recently did something like this too to make the player constantly follow the mouse when the left button is pressed, works better than i thought for some games.
i made this script to see if i could make something simple but without using if statements at all
cuz i saw a post about guy talking about how he avoids ifs statements if he can and i think he gave some pretty good reasons for it
this is what my script looked like before
game:GetService('ContextActionService'):BindAction(' ', function(string,state,input)
if state == Enum.UserInputState.Begin then
if input.KeyCode == Enum.KeyCode.W then
w = 1
elseif input.KeyCode == Enum.KeyCode.A then
a = 1
elseif input.KeyCode == Enum.KeyCode.S then
s = 1
elseif input.KeyCode == Enum.KeyCode.D then
d = 1
end
elseif state == Enum.UserInputState.End then
if input.KeyCode == Enum.KeyCode.W then
w = 0
elseif input.KeyCode == Enum.KeyCode.A then
a = 0
elseif input.KeyCode == Enum.KeyCode.S then
s = 0
elseif input.KeyCode == Enum.KeyCode.D then
d = 0
end
end
end,false,'w','a','s','d')
game:GetService('RunService'):BindToRenderStep(" ", 100, function()
Player:Move(Vector3.new(a-d,0,w-s), true)
end)