Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How does Clone() work?

Asked by
iNicklas 215 Moderation Voter
9 years ago

I'm not the sharpest knife in the drawer when it comes to this. I got a gui in lighting and i want it to clone into a players playergui when the join my place.

local Player    = game.Players.LocalPlayer
local gui       = game.Lighting["GUI"]

function OnEnter(player)

end

Player.PlayerAdded:connect(OnEnter)

1 answer

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

:clone() does what its name says! It copies the object, and places it wherever you choose it to. For example, if you want it to clone a GUI into a Player's PlayerGui when they first join, you wouldn't need to use LocalPlayer. You can have it as a normal script in Workspace.

gui = game.Lighting["GUI"] -- doesn't need to be local

game.Players.PlayerAdded:connect(function(player)
    gui:clone().Parent = player.PlayerGui
end)
Ad

Answer this question