Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my weapon saving script not saving new weapons?

Asked by 4 years ago

THIS SCRIPT ALWAYS WORKS BUT ITS ONLY LOADING WEAPONS WHEN U JOIN AND NOT SAVING THEM WHEN U LEAVE SO IF U GET A NEW WEAPON IS DOESNT SAVE PLS HELP ME

01local ds = game:GetService("DataStoreService"):GetDataStore("ToolSave")
02game.Players.PlayerAdded:Connect(function(plr)
03    local key = "id-"..plr.userId
04    pcall(function()
05        local tools = ds:GetAsync(key)
06        if tools then
07            for i,v in pairs(tools) do
08                local tool = game.ServerStorage.Tools:FindFirstChild(v)                
09                if tool then
10                    tool:Clone().Parent = plr:WaitForChild("Backpack")
11                    tool:Clone().Parent = plr:WaitForChild("StarterGear")
12 
13                end
14            end
15        end
View all 34 lines...
0
Why does line 27 have the F word on it? Dovydas1118 1495 — 4y
0
You definitely should not be using curse words in your code. Roblox goes through code, and that can get you banned and or terminated. DarkDanny04 407 — 4y
0
oh i didnt know ill remove it sorry coolmanHDMI 72 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Here's what u wanted, i didn't test it tho

01local Players = game:GetService("Players")
02 
03game:BindToClose(function()
04    for i,v in pairs(Players:GetPlayers()) do
05    local key = "id-"..v.userId
06    pcall(function()
07        local toolsToSave = {}
08        for l,k in pairs(v.Backpack:GetChildren()) do
09            if v then
10                table.insert(toolsToSave,k.Name)
11            end
12        end
13        for s, d in pairs(v.Character:GetChildren()) do
14            if you.ClassName == "Tool" then
15            table.insert(toolsToSave,d.Name) 
View all 21 lines...
Ad

Answer this question