Interval is empty math.random #2

local Part = game.Workspace:WaitForChild("RandomImageOrSomethingMan")
local Folder = workspace:WaitForChild("Rooms")

task.wait(1)
local function Image()
	if Part:FindFirstChild("Decal") then
		Part.Decal:Destroy()
	end
	local Items = #Folder:GetChildren()
	local Modl = Folder:GetChildren()[math.random(1, Items)]
	local Clone = Modl.kk.Decal:Clone()
	Clone.Parent = Part
	Clone.Face = "Top"
end

while task.wait(3) do
	Image()
end

this worksfine the first time but after that it keeps saying interval is empty in #2

I would recommend putting in a print command to check if the itemsfolder has something inside

local Part = game.Workspace:WaitForChild("RandomImageOrSomethingMan")
local Folder = workspace:WaitForChild("Rooms")

task.wait(1)
local function Image()
	if Part:FindFirstChild("Decal") then
		Part.Decal:Destroy()
	end
	local Items = #Folder:GetChildren()
    print(Items) -- with this you can check if somethings wrong with the Items-folder
	local Modl = Folder:GetChildren()[math.random(1, Items)]
	local Clone = Modl.kk.Decal:Clone()
	Clone.Parent = Part
	Clone.Face = "Top"
end

while task.wait(3) do
	Image()
end

There’s probably nothing inside the folder, which causes this error. So in this case the print command will probably say 0. If it is 0, then you need to find out why the folder is empty.

yeah i think i delete all the items in the folder to increase preformance because there are a LOT of items

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.