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

Model won't clone to workspace from script?

Line 12 and 13 won't clone?

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
		local cloned = v:Clone()
		cloned.Parent = game.Workspace
        v:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position) + CFrame.new(15,0,0))
			
		
	end
end
end

	end)
		

Thanks!

1 answer

        local cloned = v:Clone()
        cloned.Parent = game.Workspace
        v:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position) + CFrame.new(15,0,0)

You are setting the primary part CFrame of the original model, v, not the cloned model, cloned.

Here's what your code should look like:

        local cloned = v:Clone()
        cloned.Parent = game.Workspace
        cloned:SetPrimaryPartCFrame(CFrame.new(script.Parent.Position) + CFrame.new(15,0,0)

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