You're actually super close. There's a few ways you can do this involving tables but it looks like you have your parts named as Part1, Part2, etc. so I'm just going to change your variable a bit:
local numplayers = #game.Players:GetChildren()
while true do
if numplayers <= 8 then
for i,v in pairs(game.Players:GetPlayers()) do
part = game.Workspace.Folder["Part".. tostring(i)]
local hrp = v.Character.HumanoidRootPart
hrp.CFrame = CFrame.new(part.Position + Vector3.new(0,5,0))
end
end
wait(5)
end
Because i is the number of times the for loop has run at that point, it will start at 1 and go up to however many players you have. If you're unfamiliar with strings, what I'm doing is taking the string, "Part", and then adding .. after which allows you to attatch strings together. Example:
print("Hello World")
print("Hello".. " World")
What I'm doing after the .. is adding a tostring() because i is a number value and we need it to be a string for our purposes. This should work however I don't have access to studio at the moment so if it doesn't than comment any errors.
2 comments
Sorry about that, forgot to add a wait so the script may have been timing out causing it not to work. I fixed it to where it should work now lol.
thank you so much