Not necessarily true. The laws aren't 100% effective at preventing these types of events. Probably not even 50% or 25%.
However more laws enacted casts a wider net of obstacles that maybe 1 or 2 potential perpetrators get caught up in.... which could deter them, slow them down, or even prevent the entire thing. That alone is worth it IMO.
Yes they can obtain illegally, use a car, a knife or knives...but making it more difficult to obtain legally could raise some flags if other risk factors exist (maybe a past threat of violence, violent history, etc). That puts them on the radar of law enforcement and makes it more difficult to carry out their act. And that's just really basic and the tip of the iceberg. There are so many variables involved that could allow for gun legislation to have an effect on these events.