game.Players.PlayerRemoving:Connect(function(Player)
local toolInHand = Player.Character:FindFirstChildOfClass("Tool")
print(Player, Player.Character)
print(toolInHand)
if toolInHand then
toolInHand.Parent = Player.Backpack
end
end)
So here I have a part of the script to get the player’s tool in hand, but it writes nil in the output for some reason. Why? P.S. if what I have in another script also writes nil.
explaining. I have a store of different items in my game. A player can go to the store and buy an item with currency. Then he can equip it. BUT!!! I need that when you exit the game saved what things he bought and actually that in the store it is also shown. That’s why I save the current item of the player, and others. I hope I explained well)
Yeah, that’s what I thought, too. BUT!!! I have a script to equip an item from the store:
local equipped = player.Character:FindFirstChildOfClass("Tool")
print(equipped)
Here I’m just looking for an item in the player’s hand, and I only call it when the equipment button is pressed to replace the item. But it still equals nil
and do you know any articles on how to save items specifically, I know how to save Value, I also use dataStore for that. But saving an item is quite different, at least I think so.
Exactly what he said. Obviously it’s more complicated than that. But that’s the gist of it. Make a value for each of the tools in the game, if the players buy that tool then get the value with the same name as the tool and set it to true. When the players has joined the game again, loop through each value and see if it’s true, if one of the values are true, then get the tool with the same name as the value, then clone it to the players backpack.