How do I use clone() function?

I read api clone and I assume Its not Instance.clone() as it says on page.

9 Likes
local part = game.Workspace.Part
local ClonedPart = part:Clone()
6 Likes

Great answer! I get how to clone a part now. Can I ask why clone function located after part and colon?

2 Likes
local baseplate = workspace.Baseplate
local clonedBaseplate = baseplate:Clone()

-- I would recommend parenting it if you plan to use the clone lol

clonedBaseplate.Parent = workspace

Hoped this helped :grinning:

9 Likes

because clone is a built in function and it needs to know what instance it is cloning before running the function.

Edit: same as connecting functions to other stuff like

script.Parent.Touched:connect(function()

end)
3 Likes

This is because you have to declare the part and then call out the instance.
Lua does not have Clone.Part, which makes part:Clone() better.

1 Like

why would you do parenting? It seems like Baseplate already belongs to workspace in first line.

1 Like

Because when the clone is created it is not parented.

1 Like

Please read the api and documents on the devforum before asking questions like this, thanks.
You parent it to make sure it gets in the correct place.
If you do :Clone() it will just get placed in nowhere, which makes the .Parent a useful solution to give your clone a place to be.

1 Like

The first line is referencing to the already existing Baseplate not the Clone

1 Like

Got It! Thanks for answering haha.

3 Likes

Mark your solution if you have your answer, in order to avoid this thread being revived.

4 Likes

Lack of knowledge in event yet so pass haha…

1 Like