# One-way spike strips not working correctly

Hey! I’m trying to make permanent spike strips, that only work from one way (one side). In other words, if you drive onto it from the front (for example), it won’t do anything, if you drive onto it from the back, it will pop your tires.

The spike strips functionality itself works, thats fine, it’s just the checking for the way (side) they went from.

Currently it’s using angle maths, but it doesn’t work very well, cuz the angles change a lot, so it’s not that easy to make a corresponding value for each way. (ignore the < 20 value, I was just experimenting around with numerous numbers, though nothing seemed to work perfectly)

``````					local Facing = hit.Parent.Parent.DriveSeat.CFrame.LookVector
local Vector = (v.Position - hit.Parent.Parent.DriveSeat.Position).unit
local Angle = math.acos(Facing:Dot(Vector))

print("math.deg(Angle): "..math.deg(Angle))
if math.deg(Angle) < 20 then
``````

Forgot to mention: “hit” is an individual vehicle wheel, and “v” is a specific spike strip

Instead of using acos, you should be able to just use dot, then check whether that value is positive or negative.
If it’s positive, then the 2 vectors are in the same direction.
If it’s 0, then the 2 are perpendicular
If it’s negative, then they are in the opposite direction.

2 Likes

Thanks for the response!

Any idea why this happens? (The tires shouldn’t have popped, as they’re going in the correct direction).

``````					local Facing = hit.Parent.Parent.DriveSeat.CFrame.LookVector
local Vector = (v.Position - hit.Parent.Parent.DriveSeat.Position)
local Angle = Facing:Dot(Vector)

if Angle < 0 then
``````