Parenting a object to 2 people

Hello there,

I’m trying to parent a object to 2 people for a Lobby system: The Owner of the lobby gets a gui and the members gets a GUI to.

I’d look something like this:

Frame.Parent = Player and Player2

But that won’t work, I don’t know what other way or if this is possible.

Any help is appreciated, Thanks.

Before parenting the Instance to the players, create a clone that will be given, instead. This will ensure that the initial GuiObject remains unmodified while also allowing as many players as you’d like to receive the same GuiObject:

Example:

for _, player in ipairs(playerList) do

    local clonedFrame = Frame:Clone()

    clonedFrame.Parent = -- Directory of the intended ScreenGui for each player
end

Resources

Instance:Clone() Documentation

Instance.Parent Documentation

1 Like

You can’t parent something to 2 parents, as something can only have one parent, you have to clone the frame you want to give to both of them, as @StrongBigeMan9 mentioned

1 Like

Thing is, Say I want to parent it to player and PlayerList. How would I do that?

You’d clone it using Instance:Clone()

For example

local thing = whatYouWantToClone
local thing2 = thing:Clone()
thing.Parent = Parent1
thing2.Parent = Parent2
1 Like

Yea that was a simple fix I couldn’t even see, This is what happens when you work alot and find a issue.

Thanks though!

1 Like