I've been trying to delete a specific object in the workspace when a specific player leaves.
There's a folder full of int values, the int values hold the names of the players that are in the game, when one of the players leave, I want the int value with their name to be removed. Any idea how to do this? I've tried PlayerRemoving and a loop to find if the player was in the game or not but I couldn't get them to work. PlayerRemoving deleted the wrong value, and the loop just deleted all of them. Here is the loop that I used:
wait(1)
local Player = script.Parent.Parent.Parent
while true do
wait()
local Entry = workspace.Roster:FindFirstChild(Player.Name)
if Entry ~= nil then
local PlayEntry = game.Players:FindFirstChild(Entry)
if PlayEntry == nil then
Entry:Destroy()
end
end
end
Thanks for reading

2 comments
It seemed like your solution worked. I'd like to do some more testing before I accept the answer though. Thanks!
ok (I know this will work)