Need help to make this more randomised

I want to make this script to chose the Children inside the Arc folder randomly instead of following numeric orders (as shown in this video: https://streamable.com/bfrjo4). inside the folder, there’s A1, A2, A3 and so on til A12.

script.Parent.MouseButton1Click:connect(function()
	for i,v in pairs (workspace.Folder.Arc:GetChildren()) do
		task.wait(.5)
		for i,w in pairs (v:GetChildren()) do
			if w.Name == "rotator" then
				w.UpDown.TargetAngle = 135
			end
		end
	end
end)

What i meant by random is that, instead of it doing like what’s in the video, I want them to go by random. like A2, A7, A3, A1 etc. First time scripting so I get a bit confused on these yet

script.Parent.MouseButton1Click:Connect(function()
    local arcsList = workspace.Folder.Arc:GetChildren()

	for i in #arcs do
        local randomArc = table.remove(arcsList, math.random(1, #arcsList))

		for i, v in randomArcs:GetChildren() do
			if v.Name == "rotator" then
				v.UpDown.TargetAngle = 135
			end
		end

		task.wait(.5)
	end
end)
1 Like

the “#arcs” are lined in red.
image
image
^here’s the directory, i also changed their name to Mini## instead.

Ahh, my bad arcs should arcsList. Just make sure the folder in which contains the arcs is named Arcs or just edit the line of code at the top, it’s yo choice.

Ah okay, now it works. thank you so much! This place’s very helpful :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.