Hey! So I need a tools saving system, So I got one
local dss = game:GetService("DataStoreService")
local toolsDS = dss:GetDataStore("ToolsData")
local toolsFolder = game.ServerStorage.Tools
game.Players.PlayerAdded:Connect(function(plr)
local toolsSaved = toolsDS:GetAsync(plr.UserId .. "-tools") or {}
for i, toolSaved in pairs(toolsSaved) do
if toolsFolder:FindFirstChild(toolSaved) then
toolsFolder[toolSaved]:Clone().Parent = plr.Backpack
toolsFolder[toolSaved]:Clone().Parent = plr.StarterGear
end
end
plr.CharacterRemoving:Connect(function(char)
char.Humanoid:UnequipTools()
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local toolsOwned = {}
for i, toolInBackpack in pairs(plr.Backpack:GetChildren()) do
table.insert(toolsOwned, toolInBackpack.Name)
end
local success, errormsg = pcall(function()
toolsDS:SetAsync(plr.UserId .. "-tools", toolsOwned)
end)
if errormsg then warn(errormsg) end
end)
But the problem is that when the tool is inside the character (the player is holding the tool) and I leave the game, Once I rejoin it does not save
Well it doesn’t work because when you hold a tool in roblox the tool becomes a child of your character, so instead get the player’s character and get an array of its children. Use an if statement to check if its in the player’s character.
Just where you define the player and character other than that no, I am a little new to the forum and still have not figured out code boxes as they are very confusing, I edited it to show it correctly, You just need to put this in a local script in starterplayerscripts
I don’t see why I cannot post a more efficient code than what was posted above… Unless you have some problems yourself, then that’s on you. Technically, I’m not reposting your code
It literally is my exact code as I provided what you could do to implement it and a easy way to implement it easily but less efficent for the game, Honestly I don’t understand why you are reposting people’s code just to farm likes, if you want to farm likes or shares or whatever just go to tiktok or instagram, The devforum is supposted to be used to help people, not just farm likes so you can get fancy badges.