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

Is there a way to clone models from tables?

Here is some example code of what I want to accomplish:

local sky = workspace.Sky:GetChildren()
local repStorage = game.ReplicatedStorage
local severeRisk = repStorage.SeverityRiskValue.Value

local cloudTable = {
repStorage.Cloud1, 
repStorage.Cloud2, 
repStorage.Cloud3}

while repStorage.EventReady.Value == true do
	for i, storm in pairs(sky) do
		local stormType = storm.StormType.Value
		
		local growChance = math.random((stormType * 6), 100)
		if growChance > severeRisk then
			local nextCloud = cloudTable{stormType + 1}
			local cloud2 = nextCloud:Clone()
			cloud2.Parent = storm.Cloud
		end
	end
end

This code does not work because cloning models from tables is not possible. Is there any other way I could attempt something like this?

1 answer

i don't know where you got that idea from, because cloning models from tables is completely possible

tables are just storage devices for other values, the only restrictions on them are when you try to pass them through bindables or remotes, or save them in datastores

the problem is in this line right here

local nextCloud = cloudTable{stormType + 1}

you don't index tables with {}, you index them with [], so that line should be

local nextCloud = cloudTable[stormType + 1]

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