How to change properties of a clone of a group

Hello.

So, I created a script which should randomize chest spawns and make random chests, but I can’t change the values of the clones of groups, and I want to know how to do that. The script is as follows:

--Variables
local Point1 = script.Parent:WaitForChild("Point1")
local Point2 = script.Parent:WaitForChild("Point2")
local CommonChest = game.Workspace.CommonChest
local Pos1 = Point1.Position
local Pos2 = Point2.Position
--Positions
local X1 = Pos1.X
local Y1 = Pos1.Y
local Z1 = Pos1.Z
local X2 = Pos2.X
local Y2 = Pos2.Y
local Z2 = Pos2.Z
--Loop
while true do
	--Get random coordinates
	local xRand = math.random(math.min(X1, X2), math.max(X1, X2))
	local yRand = math.random(math.min(Y1, Y2), math.max(Y1, Y2))
	local zRand = math.random(math.min(Z1, Z2), math.max(Z1, Z2))
	--Execute
	if math.random(1,10) <= 5 then
		CommonClone = CommonChest:Clone()
		CommonClone.Transparency = 0
		CommonClone.Anchored = false
		CommonClone.Position.X = xRand
		CommonClone.Position.Y = yRand
		CommonClone.Position.Z = zRand
		print("Successfully created a Common Chest!")
	else
	if math.random(5,10) <= 7 then
			print("Successfully created a Rare Chest!")
		else 
			if math.random(8,10) <= 9 then
				print("Successfully created an Epic Chest!")
			else 
				print ("Successfully created a legendary chest!")
			end
		end
	end	
	--Debug/Waittime
	print("Looped!!!!!!")
	local waittime = math.random(1,5)
	wait(waittime)
	--Destroy Clones Before Next Loop Starts
	CommonClone:Destroy()
end

Any help will be greatly appreciated.

What error code do you receive?

1 Like

[Transparency is not a valid member of Model]
I’m sure this would apply to all the other property-changes in the script.

An error message almost always tells you what is wrong. It looks like you’re trying to set a ‘Transparency’ property of a model, but model instances don’t have a Transparency property. You need to change the transparency of the parts inside the model, instead.

3 Likes

That’s what I thought was the problem. Thanks for your feedback.

On the developer forum, make sure to always include an error code. Before posting, make sure to look up the error code as well!

Response above states the solution.

Best of luck,

MysteriouslyMythical
Lead Programmer

1 Like