Hello.
I have created a script which would generate chests in random positions, and in theory it should work. But, the chests aren’t appearing for some reason. The transparency of the original chest is 0, but it’s still invisible. I have created a print which would print coordinates, and the chest should be there, but it isn’t. The script is as follows:
--Variables
local Point1 = script.Parent:WaitForChild("Point1")
local Point2 = script.Parent:WaitForChild("Point2")
local CommonChest = game.Workspace.CommonChest
local CommonChestBody = CommonChest.Body
local CommonChestHead = CommonChest.Head
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
--Debug/Waittime
print("Looped!!!!!!")
local waittime = math.random(1,5)
wait(waittime)
--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:MoveTo(Vector3.new(xRand,yRand,zRand))
print("Successfully created a Common Chest!")
delay(waittime, function()
pcall(game.Destroy, CommonClone)
end)
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
print(xRand,yRand,zRand)
end
Any help will be greatly appreciated.