Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Do I Clone My Model From ServerStorage and From Touching A Part?

Hi, I just started learning so please bear with me. I'm trying to clone a model called Test562 from the ServerStorage and from touching a part.

part = script.Parent

part.Touched:Connect(function()
local test2 = game.ServerStorage.Test562
test2.Parent = game.Workspace 
end)``

And if you guys can tell me how I can place the model to a specific position, that would be amazing.``

1 answer

✓ Accepted answer

To make a copy of any instance with Archivable set to true, use Clone().

If you also want to position the model, use SetPrimaryPartCFrame(). (You have to set the PrimaryPart first because the PrimaryPart is nil by default.) Example:

local part = script.Parent -- Please use local variables
local debounce = true
part.Touched:Connect(function()
	if debounce == false then return end
	debounce = false
	if game:GetService("ServerStorage"):FindFirstChild("Test562") then
		local test = game:GetService("ServerStorage").Test562:Clone()
		test.Parent = workspace
		if test.PrimaryPart == nil then
			test.PrimaryPart = test.Core -- Assign the primary part first. Core is just an example of a child.
		end
		test:SetPrimaryPartCFrame(CFrame.new(Vector3.new(1,1,1)))
	end
	wait(3)
	debounce = true
end)

1 comment

0

Thank you so much

This discussion is preserved as it was. New answers, comments, and votes are closed.