Need help with loop

  1. What do you want to achieve? I wan’t a script that loads all the crates, get their CFrame and teleports them to localplayer

  2. What is the issue? My issue is that I don’t know how to load all the crates, get their CFrame from main because I have multiple similliar names… this is my explorer: Screenshot_3

I tried to do this, but it only teleports one crate to me

local player = game:GetService("Players").LocalPlayer
local getcrates = game:GetService("Workspace").crates.crate.main
for i, v in pairs(getcrates:GetChildren()) do
getcrates.main.CFrame = player.Character.HumanoidRootPart.CFrame
end
local getcrates = game:GetService("Workspace").crates

for i, v in pairs(getcrates:GetChildren()) do
if v.Name == "crate" then 
v.main.CFrame = player.Character.HumanoidRootPart.CFrame
end
end
1 Like

Hello, tysm <3 Hope you have a good rest of your day :slight_smile: