Hello, so today I was trying to make a player keep certain items like room keys when they reset. Currently, it works, unless they are holding the key in there hand. However, I need ALL room keys to be given back when they reset. Thanks!
local p = game.Players.LocalPlayer
local cards = {}
p.CharacterRemoving:connect(function(char)
cards = {}
for _,obj in pairs(p.Backpack:GetChildren()) do
if obj then
if string.sub(obj.Name, 1, 4) == "Room" then
table.insert(cards, obj)
end
end
end
end)
p.CharacterAdded:connect(function(char)
for _,obj in pairs(cards) do
obj.Parent = p.Backpack
end
cards = {}
end)

4 comments
If they are holding it it would be in their Character rather their Backpack so you could check if it's in their Character.
This code is checking in the backpack, he wants everything in the backpack to be stored.
Fire, that is incorrect. And Essential, I tried adding that code in, and it kept giving me errors, so I removed it(I don't have that code anymore).
Could you not just put it into StarterGear then remove it from there when they don't need the key anymore?