Help teleporting a part to the localplayer

I want to bring all the " Main " but theres more than one group of them and it just tps one to me, how to make it work?

for index, object in next, game:GetService("Workspace").Entities["OP Money Printer"]:GetChildren() do
		if object:IsA('Part') then
			if object.Name == "Main" then

game:GetService("Workspace").Entities["OP Money Printer"].Main.CFrame = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame
end
end
end

Try this:

for i in pairs(workspace.Entities["OP Money Printer"]:GetChildren()) do
    if object:IsA(‘Part’) then
    if object.Name == “Main” then
        i.CFrame = CFrame.new(game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame)
    end
end

Also, I highly recommend formatting your code, as well as putting it inside of two ```'s.

1 Like

It doesnt work, also, it should be like this:

for i in pairs(workspace.Entities["OP Money Printer"]:GetChildren()) do
    if object:IsA("Part") then
    if object.Name == "Main" then
        i.CFrame = CFrame.new(game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame)
    end
end
end
1 Like

Does it works if you replace the object variable with i?
I forgot to change that

1 Like

Change

game:GetService("Workspace").Entities["OP Money Printer"].Main.CFrame

To

object.CFrame

no, it doesnt, i dont really know what do you wanna mean

what do you wanna mean i dont understand you

Replace that part with what I said

its already like that … idk what do you wanna mean

Use this script

for index, object in next, game:GetService("Workspace").Entities["OP Money Printer"]:GetChildren() do
	if object:IsA('Part') then
		if object.Name == "Main" then
			object.CFrame = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame
		end
	end
end

Nope, it just brings one and not all of them

Are all of them named “Main”? If not this won’t work.

yeah, let me send screenshot:
image

I can’t see anything, resend it

Ok so, I hope you see this one:
image
you see it now?

You loop through 1 of the money printers and there is only 1 main In each, lemme fix the code for you.

Here

for index, object in pairs(game:GetService("Workspace").Entities:GetDescendants()) do
	if object:IsA('Part') then
		if object.Name == "Main" and object.Parent.Name ==  "OP Money Printer" then
			object.CFrame = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame
		end
	end
end
1 Like