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

My model won't clone / parent properly?

For some reason my model doesn't clone on line 11, v is a model called "1". Thanks!

local levels = game.ServerStorage.Levels:GetChildren()
local selectedlevel = math.random(1,#levels)
local debounce = true
print(selectedlevel)
script.Parent.Touched:Connect(function()
	if debounce == true then

for i, v in pairs(levels) do
	
	if v.Name == tostring(selectedlevel) then
		v:Clone().Parent = game.Workspace
        v:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position) + CFrame.new(15,0,0))
			
		
	end
end
end

	end)
		

1 answer

local levels = game.ServerStorage.Levels:GetChildren()
local parent = workspace.Model
local cloneParent = parent:Clone()
local selectedlevel = math.random(1,#levels)
local debounce = true
print(selectedlevel)
script.Parent.Touched:Connect(function()
    if debounce == true then

for i, v in pairs(levels) do

    if v.Name == tostring(selectedlevel) then
local clone = parent:Clone()
        clone.Parent = Parent.cloneParent
        v:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position) + CFrame.new(15,0,0))


    end
end
end

    end)


1 comment

0

I am trying to clone it from server storage to workspace, I don't want 2 clones

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