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

How can I make this script more simplified, if possible?

Asked by 8 years ago

I've created a part with BodyPosition. It moves around in a circle because of the positions I've set it. There are 12 blocks that form the circle, and I had made it so it moves to each block. It feels pretty lengthy to me, however. Is there a more simplified or even an easier way to achieve the same results?

local box = game.Workspace.Box
local bodypos= box.BodyPosition
local pos1 = box.b1
local pos2 = box.b2
local pos3 = box.b3
local pos4 = box.b4
local pos5 = box.b5
local pos6 = box.b6
local pos7 = box.b7
local pos8 = box.b8
local pos9 = box.b9
local pos10 = box.b10
local pos11 = box.b11
local pos12= box.b12



while true do
    bodypos.position = pos1.Position
wait(.09)   
    bodypos.position = pos2.Position
wait(.09)                   
    bodypos.position = pos3.Position
wait(.09)               
    bodypos.position = pos4.Position
wait(.09)           
    bodypos.position = pos5.Position
wait(.09)           
    bodypos.position = pos6.Position
wait(.09)               
    bodypos.position = pos7.Position
wait(.09)               
    bodypos.position = pos8.Position
wait(.09)           
    bodypos.position = pos9.Position
wait(.09)       
    bodypos.position = pos10.Position
wait(.09)       
    bodypos.position = pos11.Position
wait(.09)           
    bodypos.position = pos12.Position
wait(.09)       

end

1 answer

Log in to vote
0
Answered by 8 years ago

See if this works:

local box = game.Workspace.Box
local bodypos= box.BodyPosition

local poses = {
    box.b1, box.b2, box.b3, box.b4, box.b5, box.b6, 
    box.b7, box.b8, box.b9, box.b10, box.b11, box.b12
}

while true do
     for i=1, #poses do
        bodypos.position = poses[i].Position
        wait(0.9)
    end
end
0
Sort of. However BodyPosition values do not seem to take any effect :( XxMitch90210xX 10 — 8y
1
Oh wait! It's because wait(0.9) is not wait(0.09) Thank you! XxMitch90210xX 10 — 8y
0
Not clear yet. Whenever I try to duplicate the model, the copied one does not work :( XxMitch90210xX 10 — 8y
1
I'm sorry again! I found the answer. The first line should be local box = script.Parent....Thanks again! XxMitch90210xX 10 — 8y
0
x3 you having troubles today man? haha NAWESOME14 40 — 8y
Ad

Answer this question