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)
Hey!
So, you wanna make sure your players have their keeps and stuff with them even after they respawn? It's soo easy!! <3 :D
So, before we get into that, lets grab some biscuits.
API:Class/Backpack
A backpack is like an inventory, which is temporary, that is, the items in a backpack won't last if a player resets/respawns or gets killed.
API:Class/StarterPack
A starterpack is also an inventory. The difference between the backpack and the starterpack is that, if you add Items to a player's starterpack, they will not be added to the backpack immediately, they will be added when the player respawns, or begins new life, aka, Simply speaking, The items in the starter pack are copied/cloned into each player's Startergear and then into backpack.
API:Class/StarterGear
This is a personal inventory that copies items from StarterPack.
How'd you use them?
While you are coding, you can just drop the items that you want to player to retain with into the Player's StarterPack
In studio, it looks like this Click Here
When the game is running, each player gets a separate "StarterGear" instance. This is there for every player. This is how it looks when the game runs.