Walking player to a specific part

Hey! I’m trying to do a script, that walks (:MoveTo()) player to a specific part from a folder of parts, depending whether another player is already touching the part or not.

Example: There are 10 parts in a folder. Part 1 and 2 are already obtained (actively touched) by another player, so player gets walked to part 3.

Now as I didn’t make a code by myself yet, I don’t require you to make me a full code, unless you really want to. I’d just appreciate some head-up on how i can do this. Thanks in advance!

1 Like

You could probably use a table with all of the given parts in and assign a true or false value for whether or not they’ve been collected.

local parts = workspace.Folder:GetChildren()
local partsCollected = table.create(#parts, false)

for i = 1, #parts do
   if not partsCollected[i] then 
      humanoid:MoveTo(parts[i].Position) 
      -- if this line doesn't work, use:
      -- humanoid:MoveTo(workspace.Folder["Part"..tostring(i)].Position)
   end
end
1 Like

Many thanks for the script! Though, it pretty much ignores the part where it checks if a player is already standing on the part. It moves both players on one part (new player to the old one’s position). Do you know how can that be fixed?

Also, is there any way of how I could prevent 2 or more players, that joined at the same time, meaning the check function got called at the same time, to go on one pad?

Many thanks in advance!

Actually nevermind, edited it to my needs already. Many thanks tho!

please mark their post as solution as not to confuse anyone and so the thread closes

I would, however it’s not a full solution. Though I’m still grateful for the script.