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.
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