I wanted to make this function run every 5 hours. It basically just clears parts in the workspace. I tried setting the wait to a lower number and it didn't work. Also, I'm pretty sure this isn't an efficient way to write this script. Could anyone help me out here?
function CleanParts()
local w = workspace:GetChildren()
for i,v in pairs(w) do
if v:IsA("BasePart") then
_G.SendMessage("All building materials are being cleaned.")
v:Destroy()
end
end
end
while wait(18000) do
CleanParts()
end

1 comment
You would multiple the amount of seconds in an hour by the amount of hours you wish for it to run for. (HoursInSecond x 5) However, I can't confirm if this'll work, although I do know that to get the amount of seconds in an hour, you multiple 60 seconds by 60 minutes, so that would probably be the case.