#Clearing player's folder

1 messages · Page 1 of 1 (latest)

karmic briar
#

How do I get a player so I can clear their folder after a bit?
When a player joins, they get a custom folder to hold parts that they created. How would I make it so it clears everyone's folder after a certain amount of time? (I dont know if I chose the correct tags for the post, they all seem confusing.)

zenith prairie
# karmic briar How do I get a player so I can clear their folder after a bit? When a player joi...

if you want it to clear over and over over a bit of time you can use a while loop like so:

-- optional: cache some stuff
local cache = {};
-- main
while task.wait(60) --[[time in seconds]] do
  print("Cleared!");
  for i, v in path.to.folder:GetChildren() do
    -- everything except Destroy() is part of caching, if you dont want to cache you can remove that
    cache = {};
    table.insert(cache, v.Name);
    v:Destroy()
  end
end
-- in the rest of the code you can access the folder like normal OR the old item names from the cache, code wont run after the while loop but you can put it in a coroutine.wrap() to make it run after

but i would recommend caching some data

muted geyser
#

game:GetService("Players"):GetPlayers()

zenith prairie
karmic briar
#

what does cache do?

zenith prairie
#

its optional but

#

it stores the old version

karmic briar
#

ok