So I have this folder in workspace called InslandSlots and each slot it has a model called Island.
After each round I wan't it to destroy() the model but I keep getting the error: ServerScriptService.Rounds:15: attempt to index a nil value
Server Script:
--Rounds
wait()
while true do
--Preparing round
Status = "PREPARING ROUND"
UpdateStatus:FireAllClients(Status)
local Islands = game.Workspace.IslandSlots:GetChildren()
for i = 1, #Islands do
local Island = Islands[i]
Island:FindFirstChild("Model"):Remove()
wait()
end
wait(10)
end
I tried to create a similar environment that I could decipher from your code, my folder is depicted here: https://prnt.sc/naby2w
I used similar code to yours without while true do because I was only attempting to do it once. This is what I procured in a script that was inserted into ServerScriptService:
wait() local islands = workspace.IslandSlots:GetChildren() for i, island in ipairs(islands) do island:FindFirstChild("Model"):Destroy() print("island destroyed") end
From just running that, I was successful, however, as I said in my comments, I don't know the full scope of your script or the workspace you are dealing with. On the oft chance that you are using Island:FindFirstChild("Model") and model isn't actually a descendent of Island, that would be your problem, but otherwise I don't honestly know what is going wrong with your script. Hope you figure it out, and that I could potentially provide some insight.