Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Conveyer script works horizontally but not vertically?

Asked by 2 years ago
Edited 2 years ago

how come these 2 that moves un-anchored parts going horizontal but not vertical?

--Horizontally

while wait() do
    script.Parent.Velocity = script.Parent.CFrame.LookVector * 3
end

--Vertically

while wait() do
    script.Parent.Velocity = script.Parent.CFrame.UpVector * 3
end

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

when the first loop begins running, it will run forever and the second loop won't continue, you can merge them together:

--Horizontally & Vertically
while task.wait() do -- use task.wait it's faster
    script.Parent.Velocity = script.Parent.CFrame.LookVector * 3 + script.Parent.CFrame.UpVector * 3
end

Okay, then you can create a new thread, this will run independently from the rest of the script, you can do that using task.spawn:

task.spawn(function()
    while task.wait() do
        script.Parent.Velocity = script.Parent.CFrame.LookVector * 3
    end
end)

while task.wait() do
    script.Parent.Velocity = script.Parent.CFrame.UpVector * 3
end
0
sorry they r not connected GameStealerKid 79 — 2y
0
I edited the script, I am not sure if this is what you expected though since the first loop will change velocity and the second one will change it again instantly it's kind of weird imKirda 4491 — 2y
0
its not the looping I'm worried about, I'm just comparing them. The horizontal 1 works but the vertical 1 doesn't. they r seperate scripts GameStealerKid 79 — 2y
0
vertical one does not work possible because only parts that are "standing" on top of the conveyor part can move, if you are going to increase the multiplier for UpVector for example UpVector * 20 you will see that the parts on top surface of the conveyor are jumping, you can fix this by using body velocity for parts that touch the vertical conveyor imKirda 4491 — 2y
Ad

Answer this question