Hi Ya Dev Forum, Want a cookie?
No I am just kidding, sorry if this has already been posted but
I couldn’t find anything similar.
I want to prevent a Player from shooting backwards, But I dont know how to make it…
Can somebody reference me a link or give me a basic idea of how to do this,
that would be much appreciated.
local lookVector --the direction the humanoid or gun is facing
local shootVector -- the direction the bullet is going
local dotProduct = shootVector:Dot(lookVector)
if dotProduct < 0 then
print("backwards")
end
The dot product function essentially sees how parallel two vectors are. You can view a visualizer here: