Would this script create ten string values or one?
local listofobjects = { ["owner"] = Instance.new("StringValue"); ["type"] = Instance.new("StringValue"); ["level"] = Instance.new("IntValue"); ["health"] = Instance.new("IntValue"); } for i = 1, 10 do listofobjects["owner"].Parent = <idk somewhere random> end
This would not work because there is only one of said Instance. The way I would get around this is by cloning the Instance and then moving it to wherever you'd like to
Here is my script:
local listofobjects = { ["owner"] = Instance.new("StringValue"); ["type"] = Instance.new("StringValue"); ["level"] = Instance.new("IntValue"); ["health"] = Instance.new("IntValue"); } for i,v in pairs (listofobjects) do for num= 1, 10 do local obj = v:clone() obj.Parent = workspace end end
Using a for loop in tables will provide two values. The 'i' will provide the name of the variable, and the 'v' will provide what the variable is equal to
As you can see, it clones each Instance 10 times and puts them into workspace
.