Yo!
So I have a problem with my DataSave system. The tools are supposed to save, but for some reason it doesn’t.
Let me show you my codes.
Save Tool Names Script
local ToolsData = {}
local function AddToolInTable(tool)
table.insert(ToolsData, tool)
end
while wait(0.1) do
for i, weaponName in pairs(player.WeaponNames:GetChildren()) do
if weaponName then
if weaponName:IsA("StringValue") then
AddToolInTable(ToolsData, weaponName.Value)
end
end
end
end
local Success, ErrorMessage = pcall(function()
DataStore:SetAsync(player.UserId, Data)
ToolsDataStore:SetAsync(player.UserId, ToolsData)
end)
Store Tool Name Script
-- Variables
local tool = script.Parent.Parent
local remote = script.Parent:WaitForChild("RemoteEvent")
-- Code
remote.OnServerEvent:Connect(function(player)
local weaponNames = player:WaitForChild("WeaponNames")
local function GiveWeapon()
if weaponNames:FindFirstChild(tool.Name) then return end
local weaponName = Instance.new("StringValue", weaponNames)
weaponName.Name = tool.Name
end
GiveWeapon()
end)