Only 1 function runs at a time

Hello, I want to be able to do 2 or more keys at a time, however when I test it, it only calls in 1 function at a time according to the order of the script, how can I rearrange this list of if functions so that I can call in 2 functions at the same time by pressing 2 buttons?

if w then
   seat.BodyVelocity.Velocity = seat.CFrame.LookVector * 100
elseif s then
   seat.BodyVelocity.Velocity = seat.CFrame.LookVector * -25
elseif e then
   seat.BodyVelocity.Velocity = seat.CFrame.UpVector * 25
elseif q then
   seat.BodyVelocity.Velocity = seat.CFrame.UpVector * -25
else
   seat.BodyVelocity.Velocity = Vector3.new(0, 0, 0)
end

This makes sense cause you should have used separate if-statements instead of an if/else chain. Pressing both ‘w’ and ‘e’ will only result in one direction with this code.

I tried to do this, however I need a place to put the last condition, the else statement otherwise my script won’t work.

Well, you could start with an empty Vector3 and add the deltas that result from the input.

For example:

local v = Vector3.zero

if w then v += Vector3.new(10, 0, 0) end

Is there a way to only use bodyvelocity as that is what my script mostly runs on?

local v = Vector3.zero

if w then v += Vector3.new(10, 0, 0) end

seat.BodyVelocity.Velocity = v

Don’t forget to modify the ifs cause this was only just an example.

Wait I forgot something, I use Cframe vectors inorder for my vehicle to work, Vector3.new only moves on an axis, is there another way to reset the vectors or basically “anchor” my vehicle in the script?

local velocity = Vector3.zero
local cframe = seat.CFrame

if w then velocity += cframe.LookVector * 100 end
if s then velocity += cframe.LookVector * -25 end
if e then velocity += cframe.UpVector * 25 end
if q then velocity += cframe.UpVector * -25 end

seat.BodyVelocity.Velocity = velocity

This correct? Also it still only does 1 function at a time and it didn’t stop moving just like before.

if w then
	vel = seat.CFrame.LookVector * 100
    end
	if s then
	vel = seat.CFrame.LookVector * -25
	end
	if e then
	vel = seat.CFrame.UpVector * 25
	end
	if q then		
	vel = seat.CFrame.UpVector * -25
	end
seat.BodyVelocity.Velocity = vel

No, you ment to use += and not =. += uses the last value and adds the next (for e.g. 1 += 1 = 2)

Yes, but how is it suppose to reset to zero.