This post is old, nothing here reflects the way i program now.
What do you want to achieve? Keep it simple and clear!
I’m creating a game in which the server chooses a block and when the custom shot hits a certain block, the block disappears, the cube remains in the serverstorage and a clone is made and the clone is placed in a workspace folder, but until then everything right, until the moment when the players finished with all the blocks of the cube, and then the game chooses a new cube and repeats, however, the model of the cube is still there, the same thing happens a lot of times, until the server can no longer handle the excess of models in a single folder, so how do I make the script delete the cube model when all the cube blocks have been deleted by the player?
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I searched a lot of things on the Developer hub, I tried GetDescendants, GetChildren, WaitForChild, FindFirstChild, GetNumAwakeParts and a ton of others, and nothing worked
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
while true do
wait(0.5)
if game.Workspace.ToDestroy.Cube:GetChildren()() == nil then
print("Cube was no blocks")
end
end```
Seriously, thank you very much, I was feeling pressured and irritated for not being able to make a simple code, I researched dying for an entire hour, thank you very much
In fact, I spent an hour looking for and testing the game on two players, I destroyed the block and for the other player the block was still there, so I sent it when the shot touched the block to trigger a remote event on the serverscriptservice and I myself solved, but I will keep as solved
Or you know just utilize events Roblox already provides you with, e.g: Instance.ChildRemoved or Instance.ChildAdded whatever concerns your situation instead of periodically checking for the number of children.