Hello, so Im using conveyors, and the way I have it go is to set the part velocity to the lookvector. However, for certain parts of it, I need it to go at a slight angle.
How would I make it so that it would always go slightly to the right, no matter the orientation.
Current code:
while true do
script.Parent.Velocity = script.Parent.CFrame.LookVector * 120
wait()
end
You can do this by rotating the CFrame first by a certain amount, and then grabbing the LookVector.
If the conveyor is anchored, you don’t need to continuously set the velocity. Just set it once; no loop required!
local speed = 120
local rotation = math.rad(20) -- Rotate by 20 degrees
-- Get rotated cframe of the parent:
local cf = script.Parent.CFrame * CFrame.Angles(0, rotation, 0)
-- Calculate and set velocity:
script.Parent.Velocity = cf.LookVector * speed
Nope, it’s not rotating the actual part. To get technical, variable cf is a copy of the part’s CFrame value, rotated by 20 degrees. It won’t actually affect the part, unless you reassigned the part’s CFrame to cf (e.g. script.Parent.CFrame = cf).
So we’re just using cf as a temporary CFrame value in memory to then grab its calculated LookVector.