Im trying to make a script that can save the tools that players gained during their journey i made this so far but is not working
local key = "keyg3n"
local players = game:GetService("Players")
game.Players.PlayerAdded:connect(function(loady)
local player = players:GetPlayerFromCharacter(loady) local backpack = player.BackPack loady:WaitForDataReady() tools = loady:loadInstance(key..player.Name) tools.Parent = backpack
end)
game.Players.PlayerRemoving:connect(function(savy)
local player = players:GetPlayerFromCharacter(savy) local backpack = player.BackPack local inventory = backpack:GetChildren() savy:WaitForDataReady() if inventory then savy:saveInstance(key..player.Name) end
end)
what is wrong on my script?
it is supposed to keep the tools that players gained whem they leave or die
NOTE: its my first time asking a question so im sorry for any mistake above
Maybe the mistake is that you wrote 'BackPack' instead of 'Backpack'. Also, for these lines
game.Players.PlayerAdded:connect(function(loady)
game.Players.PlayerLeaving:connect(function(savy)
You would replace game.Players with players.