Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

5 comments

0

Sort of. However BodyPosition values do not seem to take any effect :(

1

Oh wait! It's because wait(0.9) is not wait(0.09) Thank you!

0

Not clear yet. Whenever I try to duplicate the model, the copied one does not work :(

1

I'm sorry again! I found the answer. The first line should be local box = script.Parent....Thanks again!

0

x3 you having troubles today man? haha

This discussion is preserved as it was. New answers, comments, and votes are closed.