# Conveyor Velocity Issues

Okay, I am utmost confused right about now. Normally I would be able to solve these issues myself, but I’m stumped. I’m programming a conveyor for my game, and honestly, I expected it to take at most a minute to implement the script. but nooo. The velocity is always going in the same direction even though I’ve implemented a check for the current rotation of the conveyor, yet it instead always goes to (0, 0, 5).

I know it’s likely a very simple solution, but I honestly don’t see why this isn’t working. At first I thought maybe the script is running before the rotation is applied to the object, but that’s not the case. To sum up the issue, it’s always registering the Y orientation as being 0.

``````if Conveyor.Orientation.Y == 0 or 180 then
if Conveyor.Orientation.Y == 180 then
Conveyor.Velocity = Vector3.new(0, 0, -5)
else
--Always selecting this option even though it's not correct.
Conveyor.Velocity = Vector3.new(0, 0, 5)
end
else if Conveyor.Orientation.Y == 90 or -90 then
if Conveyor.Orientation.Y == 90 then
Conveyor.Velocity = Vector3.new(5, 0, 0)
else
Conveyor.Velocity = Vector3.new(-5, 0, 0)
end
end
end
``````

Perhaps is detecting -180? I don’t see anything to account for that. Also, I’d suggest using math.abs(Number) in your code to eliminate the need for the - at the start of negative numbers. math.abs(Number) just makes that number the positive version of itself if it is negative.

it’s easier to use the cframe for this stuff,

``````Conveyor.Velocity = Conveyor.CFrame.LookVector*5
``````
2 Likes

Ah, using math.abs did work for the first check (if it’s 0 or 180), but not the second. But it’s all well now, truthfully, I didn’t realize that could be an issue.

Yeah, that works, though I had to set it to -5 to get it moving in the proper directions. I haven’t done much with CFrames except for my placement system so I’m not quite knowledgeable on them yet. Definitely will be studying up on it soon.

be sure to mark it as solved when you got your answer :^)

1 Like