I’ve been developing a game that is mainly based on destroying objects and buildings that are welded together.
-
What do you want to achieve? Keep it simple and clear!
I want to make a script that removes loose parts in the workspace that are unanchored and aren’t welded to any other parts after a certain amount of time. -
What is the issue? Include screenshots / videos if possible!
I’ve tried a few times but it hasn’t been working and i don’t know where to start. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
It did have a script timeout, assuming because it was trying to get every single part in the workspace, so i tried to fix it, and it got rid of the error but it still doesn’t work.
This is my current script in serverscriptservice.
local debris = game:GetService("Debris")
for _, descendant in pairs(workspace:GetDescendants()) do
while true do
if descendant:IsA("BasePart") and descendant.Anchored == false and not descendant.Parent:FindFirstChildOfClass("Humanoid") then
local welded = descendant:GetConnectedParts(true)
if #welded == 1 then
debris:AddItem(descendant, 1)
end
end
wait(10)
end
end