So, I’m trying to make conveyor that moves parts. And here’s the conveyor:
(This conveyor is grouped.)
But issue is this conveyor moves parts in only one direction.
I tried detecting orientation to set velocity of conveyor, but is is not working, it only pushes in one direction.
Original Script That I Wrote:
while wait() do
script.Parent.Velocity = script.Parent.CFrame.LookVector * 10
end
The Script That Detects Direction:
local directions = {0,180,-90,90}
function calculate(pow)
local rot = script.Parent.Orientation.Y
if rot == directions[1] then
return script.Parent.CFrame.LookVector * pow
elseif rot == directions[2] then
return -script.Parent.CFrame.LookVector * pow
elseif rot == directions[3] then
return -script.Parent.CFrame.RightVector * pow
elseif rot == directions[4] then
return script.Parent.CFrame.RightVector * pow
end
end
while wait() do
script.Parent.Velocity = calculate(5)
end
A quick note: I tried to removing main conveyor from group and rotated it. But velocity on conveyor keeps setting to 0,0,0.
But you have a while loop setting the velocity in the original script, if you change it from the other script then the while loop will set it back to what it was
As you can see, I removed conveyor part (In red circle) from conveyor model and Tried to clone in game using my placing script, but It’s velocity properties is (0,0,0). Even the enabling script after delay didn’t work.
Are you absolutely sure that your orientation Y value changes when you rotate it correctly as well as that it’s not stuck at the same number even when rotated?
For example, if you rotate the conveyor, the orientation Y value should change correctly by only the direction values you have in the table and it should change for it to work.
I solved this problem, I need to do is removing velocity script and writing this code in the conveyor placing script (It places random direction because testing) :
local a = {0,90,180,-90}
local rot = a[math.random(1,4)]
b.Orientation = Vector3.new(0,rot,0)
b.Velocity = b.CFrame.LookVector * 5