#Tool data store

1 messages · Page 1 of 1 (latest)

raw mantle
#
local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
game.Players.PlayerAdded:Connect(function(plr)
    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")
    local success , toolstable = pcall(function()
        return toolsdata:GetAsync(plr.UserId)
    end)
    
    if success and toolstable then
        for _ , eachtool in pairs(toolstable) do
            local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
            if tool then
                local newtool_folder = tool:Clone()
                local newtool_back = tool:Clone()
                newtool_folder.Parent = tools_folder
                newtool_back.Parent = Backpack                
            end
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(plr_leave)
    local tools = {}
    local tools_folder = plr_leave:FindFirstChild("Tools_Folder")
    for _, eachtool in pairs(tools_folder:GetChildren()) do 
        table.insert(tools , eachtool.Name)
    end
    
    local success , error = pcall(function()
        return toolsdata:SetAsync(plr_leave.UserId , tools)
    end)
    
    if not success then
        warn(plr_leave.Name .."Didn't save tools data: ".. error)
    end
end)
```Here idk why tools come to toolsfolder but not backpack
vagrant gull
#

Not sure if the newtool_folder is supposed to clone the tool

local newtool_folder = tool:Clone()
local newtool_back = tool:Clone()
newtool_folder.Parent = tools_folder
newtool_back.Parent = Backpack                
honest dove
#

he just creates 2 variables cause he didnt know how to else to clone it 2 times thats why its like this prolly, but that part is correct

#

@raw mantle did you check the explorer if the player has the tool there?

raw mantle
honest dove
#

no thats fine

raw mantle
#

yep still

honest dove
#
tool:Clone().Parent = tools_folder
tool:Clone().Parent = Backpack                

y could just simplify it

raw mantle
#

and when i say print backpack getchildern output: [1] = Tool

honest dove
#

look at the explorer and go into the backpack

raw mantle
honest dove
#

hm

raw mantle
honest dove
#

wait make the tool a variable

#

and then print the tool to see where it is and after parenting it print it again

#

this way we can see if it clones right

#

and parents right

raw mantle
#

ok u mean i do print newtool_back.parent ?

honest dove
#
local backpackTool = tool:Clone()
tool:Clone().Parent = tools_folder

print(backpackTool)
backpackTool.Parent = Backpack    
print(backpackTool)
#

like this

raw mantle
#
if tool then
                
                tool:Clone().Parent = tools_folder
                tool:Clone().Parent = Backpack           
                
            end
```i edit this part
honest dove
#
if tool then
    local backpackTool = tool:Clone()
    tool:Clone().Parent = tools_folder

    print(backpackTool)
    backpackTool.Parent = Backpack    
    print(backpackTool)        
end
raw mantle
#
if success and toolstable then
        for _ , eachtool in pairs(toolstable) do
            local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
            if tool then
                local newtool_folder = tool:Clone()
                local newtool_back = tool:Clone()
                newtool_folder.Parent = tools_folder
                
                print(newtool_back.Parent)
                newtool_back.Parent = Backpack  
                print(newtool_back.Parent)
            end
        end
    end
```like this ?
honest dove
#

yes

raw mantle
#

oh

honest dove
#

and now see where its located before and after

raw mantle
#

output nothing

honest dove
#

then the folder isnt working aswell

raw mantle
#

oh wit there is no data i will resave it

honest dove
#

print the tool before your if statement

#

o okay

raw mantle
#

output: nil
output: Backpack

#

hooow Y_Y

#

i print backpack.parent ?

#

ok idk what is problem is it bug ? @honest dove

honest dove
#

nono just print newtool_back not the parent

#

but i think how you are trying to save ur tools is the problem

raw mantle
honest dove
#

you cant actually save the whole tool you have to give every tool an ID save the IDs and then wehn it loads you have to convert these IDs to the tools again

#

you can only save tables, strings, bools, numbers

#

no tools/instances

raw mantle
honest dove
#

o

raw mantle
#
table.insert(tools , eachtool.Name)
honest dove
#

wait

raw mantle
#

ok

honest dove
#

mb ur correct

raw mantle
#

i am sure that problem not when player leave bec when i test tool.parent = folder_tools and its tool

#

but dont go to backpackk

honest dove
#

and not the parent

#

so we can see if it clones and where its then located and where its located after parenting

raw mantle
#

what ?

#

if i remove parent it will print tool name

honest dove
#

it will print the tool instance

#

and wehn you click it it will show you the position of it in the explorer

raw mantle
#
if tool then
                local newtool_folder = tool:Clone()
                local newtool_back = tool:Clone()
                newtool_folder.Parent = tools_folder
                
                print(newtool_back)
                newtool_back.Parent = Backpack  
                print(newtool_back)
            end
#

like this ?

raw mantle
#

output Tool

#

but 2 lines bec i say print 2 times

honest dove
#

zes

#

now click on it like i did

#

and see where its located

raw mantle
#

ok

#

sorry i went afk

honest dove
#

all good

raw mantle
#

doesnt show any thing

#

like its parent = nil

#

i print backpack get children ?

honest dove
#

so it doesnt show the tool in the explorer

raw mantle
#

Can i give u game files so u can see problem better ?

#

this game i didnt do any thing on it lol

honest dove
#

alr

raw mantle
#

ohh i see maybe problem

#

print(newtool_back.Parent)
Here output backpack but when i press it nothing apear

#

that means backpack is nil too

honest dove
#
local Backpack = plr:FindFirstChildOfClass("Backpack") or plr:WaitForChild("Backpack")

try this

thin dragon
raw mantle
#

yep no change

thin dragon
#

because im pretty sure its going to do what you want

raw mantle
#

u mean put tool for example in my player name ?

thin dragon
vast veldtBOT
#

studio** You are now Level 6! **studio

honest dove
#

i mean thats a workaround but the save wont work then

raw mantle
thin dragon
#

because that is not true

raw mantle
#

if i want the humanoid or anything inside charcter then i could make charcter but backpack not inside charcter

honest dove
#

he meant that you just put the tools in your char

#

this works

#

but will completly fuck up your saving

#

I wanna know why it wont work in the backpack tho

raw mantle
#

ok so what i do is local charc = plr.cha......
and then put newtool_back.parent = char ?

thin dragon
#

and adding multiple would break it

#

so

#

uhh

raw mantle
#

ohh wit !!

#
newtool_back.Parent = game.StarterPack
#

here its goes to starterpack

#

soo problem in backpack not clone

#
newtool_back.Parent = plr:FindFirstChild("Backpack") or plr:WaitForChild("Backpack")
#

also this dont work

#

i will just keep it at folder maybe there is bug

thin dragon
#

ok how about just put a breakpoint and see if anything goes wrong

raw mantle
thin dragon
honest dove
#

and startpack also just puts it in the char

#

but why the hell wont the backpack work

raw mantle
#

ok i have diffrante idea maybe roblox do when player join i cant give tool to backpack soo i will add diffrante script and put task.wait(1) then add this tool

#

if it worked soo there was a bug

thin dragon
honest dove
raw mantle
thin dragon
honest dove
#

i also dont think so the problem is in how your getting the backpack

#

im trying to figure it out rn

#

whats ur code now fake_name1?

raw mantle
raw mantle
#

it works so problem here is on backpack bec when i say print backpack and press it nothing happen

thin dragon
#
local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
game.Players.PlayerAdded:Connect(function(plr)
    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")
    local success , toolstable = pcall(function()
        return toolsdata:GetAsync(plr.UserId)
    end)

    print(success)    
    print(toolstable) 

    if success and toolstable then
        for _ , eachtool in pairs(toolstable) do
            local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
            if tool then
                print("passed nil tool check") 
                local newtool_folder = tool:Clone()
                local newtool_back = tool:Clone()
                newtool_folder.Parent = tools_folder
                newtool_back.Parent = Backpack                
            end
        end
    end
end)
``` just try this and see what the prints are
#

i dont think its something to do with the backpack

raw mantle
#

ok output is:

honest dove
thin dragon
#

wait was the toolstable print empty

raw mantle
#

True
{
[1] = Tool
}

passed nil tool check

raw mantle
thin dragon
raw mantle
thin dragon
raw mantle
thin dragon
raw mantle
#
local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
game.Players.PlayerAdded:Connect(function(plr)
    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")
    local success , toolstable = pcall(function()
        return toolsdata:GetAsync(plr.UserId)
    end)

    if success and toolstable then
        for _ , eachtool in pairs(toolstable) do
            local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
            if tool then
                local newtool_folder = tool:Clone()
                local newtool_back = tool:Clone()
                newtool_folder.Parent = tools_folder
                newtool_back.Parent = Backpack                
            end
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(plr_leave)
    local tools = {}
    local tools_folder = plr_leave:FindFirstChild("Tools_Folder")
    for _, eachtool in pairs(tools_folder:GetChildren()) do 
        table.insert(tools , eachtool.Name)
    end

    local success , error = pcall(function()
        return toolsdata:SetAsync(plr_leave.UserId , tools)
    end)

    if not success then
        warn(plr_leave.Name .."Didn't save tools data: ".. error)
    end
end)
```this ?
thin dragon
#

wait no

#

the newest one

#

not the old one

raw mantle
#

and tools. parent = nil

#

when i print(backpack) and click on it nothing happen so tat means backpack also nil

honest dove
#
local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
game.Players.PlayerAdded:Connect(function(plr)
    local tf = Instance.new("Folder")
    tf.Name = "Tools_Folder"
    tf.Parent = plr
    
    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")
    local success , toolstable = pcall(function()
    return toolsdata:GetAsync(plr.UserId)
end)

    if success and toolstable then
        for _ , eachtool in pairs(toolstable) do
            local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
            if tool then
                local newtool_folder = tool:Clone()
                local newtool_back = tool:Clone()
                newtool_folder.Parent = tools_folder
                
                task.spawn(function()
                    task.wait(5)
                    newtool_back.Parent = plr.Backpack
                end)
            end
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(plr_leave)
    local tools = {}
    local tools_folder = plr_leave:FindFirstChild("Tools_Folder")
    for _, eachtool in pairs(tools_folder:GetChildren()) do 
        table.insert(tools , eachtool.Name)
    end

    local success , error = pcall(function()
        return toolsdata:SetAsync(plr_leave.UserId , tools)
    end)

    if not success then
        warn(plr_leave.Name .."Didn't save tools data: ".. error)
    end
end)

this works and i have no idea why it does

raw mantle
#

omgggg

#

i fix it Y_Y

#

omg

thin dragon
raw mantle
#

i dare u guys found problem

local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
game.Players.PlayerAdded:Connect(function(plr)
    task.wait(2)
    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")
    local success , toolstable = pcall(function()
        return toolsdata:GetAsync(plr.UserId)
    end)

    if success and toolstable then
        for _ , eachtool in pairs(toolstable) do
            local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
            if tool then
                local newtool_folder = tool:Clone()
                local newtool_back = tool:Clone()
                newtool_folder.Parent = tools_folder
                newtool_back.Parent = Backpack                
            end
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(plr_leave)
    local tools = {}
    local tools_folder = plr_leave:FindFirstChild("Tools_Folder")
    for _, eachtool in pairs(tools_folder:GetChildren()) do 
        table.insert(tools , eachtool.Name)
    end

    local success , error = pcall(function()
        return toolsdata:SetAsync(plr_leave.UserId , tools)
    end)

    if not success then
        warn(plr_leave.Name .."Didn't save tools data: ".. error)
    end
end)
#

task.wait(2) make it work when player added Y_Y

#

i will really cry

honest dove
#

thats what i legit just said

raw mantle
#

but how and i say :WaitForChild ?

honest dove
#

idk why but its a diffrent backpack wehn you instantly get the backpack and 1 second later

#

@royal canyon do you know why this happens?

raw mantle
#

who @royal canyon ?

honest dove
#

very good scripter and also very got at explaining it

thin dragon
#

no but using task.wait() should'nt change anything

#
game.Players.PlayerAdded:Connect(function(plr)
    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")

    local newTool = Instance.new("Tool")
    
    newTool.Parent = Backpack
end)

this works

thin dragon
raw mantle
#

oh i change task.wait(1) and didnt work so i must write task.wait(2) ?

honest dove
# thin dragon it does though
local datastoreservice = game:GetService("DataStoreService")

game.Players.PlayerAdded:Connect(function(plr)
    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")

    local tool = game.ServerStorage.Folder:FindFirstChild("Tool")

    tool:Clone().Parent = Backpack
end)

and this doesnt work again 😭

raw mantle
#

ohh maybe i know problem

honest dove
#

this doesnt make any sense

raw mantle
#

ok i know

raw mantle
#

oh but i use wait so idk why

honest dove
#

it doesnt work for me

raw mantle
honest dove
#

this aint making any sense ong

raw mantle
#

ok problem that game need like 2 sec to load plr backpack ?

raw mantle
#

so i just keep task.wait(2) ? bec task.wait(1) dont want to work too

honest dove
#

so im assuming the backpack parenting works fine but it gets deleted and recreated?

raw mantle
thin dragon
#

or doing anything really

honest dove
raw mantle
#

problem that when i say task.wait(1) didnt work and charcter spawn in less than 1 sec

thin dragon
honest dove
#
game.Players.PlayerAdded:Connect(function(plr)
    local tf = Instance.new("Folder")
    tf.Name = "Tools_Folder"
    tf.Parent = plr

    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")

    local newTool = Instance.new("Tool")

    newTool.Parent = Backpack
end)

this doesnt work

thin dragon
#

and its just worth a shot

honest dove
#
game.Players.PlayerAdded:Connect(function(plr)
    task.wait(2)

    local tf = Instance.new("Folder")
    tf.Name = "Tools_Folder"
    tf.Parent = plr

    local tools_folder = plr:WaitForChild("Tools_Folder")
    local Backpack = plr:WaitForChild("Backpack")

    local newTool = Instance.new("Tool")

    newTool.Parent = Backpack
end)

and this does

honest dove
raw mantle
#

the problem that its same backpack Y_Y

#

idk why this happen to me when i start learn tool data store

honest dove
#

FUCK I KNOW WHATS THE PROBLEM IS

#

THE CLIENT HASNT CREATED ITS BACKPACK YET THATS WHY IT FAILS

thin dragon
#

maybe because adding a tool to a backpack that the character requires is impossible because the character doesn't exist yet

thin dragon
#

and waitforchild doesn't work for that

honest dove
#

look the server creates the backpack but then the client creates the backpack which ig overwrites the servers backpack

vast veldtBOT
#

studio** You are now Level 21! **studio

thin dragon
honest dove
#

you are waiting for the server backpack with :WaitForChild

honest dove
#

thats the only solution that makes sense

raw mantle
#

okk i will just stick with task.wait(2) there is nothing else we can do

thin dragon
#

if the client made the backpack it wouldn't show for the server so why would waiting 2 seconds work

raw mantle
raw mantle
thin dragon
raw mantle
thin dragon
raw mantle
honest dove
#
game.Players.PlayerAdded:Connect(function(plr)
    local tf = Instance.new("Folder")
    tf.Name = "Tools_Folder"
    tf.Parent = plr

    local backpack1 = plr:WaitForChild("Backpack")
    print("Backpack 1:", backpack1)

    task.wait(2)

    local backpack2 = plr:FindFirstChild("Backpack")
    print("Backpack 2:", backpack2)

    print("Same?", backpack1 == backpack2)
end)

my theory is correct

raw mantle
honest dove
#

idk

raw mantle
#

roblox studio is suck

honest dove
#

chatgpt said it could be a temporary backpack and roblox replaces it afterwards

raw mantle
honest dove
#

ima make a new thread for this and ask if anyone is aware of this problem

raw mantle
#

i dont want to blow my mind more i just too happy that i solve it

#

oh wit @royal canyon with us

#

@royal canyon can u help us on that ?

thin dragon
# honest dove ima make a new thread for this and ask if anyone is aware of this problem

nope its just this thread that proves my theory correct: https://devforum.roblox.com/t/tool-wont-be-added-in-backpack-when-player-joins/2229215

honest dove
#

ooo

thin dragon
honest dove
#

that makes sense so roblox deletes the backpack and recreates it wehnever the character reloads / in our scenario first loads

#

that also explains why we cant compare them

thin dragon
#

and waiting 2 seconds doesn't completely fix it because of different loading times

raw mantle
#

ohhhhh

#
local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
game.Players.PlayerAdded:Connect(function(plr)
    local charcter = plr.Character or plr.CharacterAdded:Wait()
    if charcter then
        local tools_folder = plr:WaitForChild("Tools_Folder")
        local Backpack = plr:WaitForChild("Backpack")
        local success , toolstable = pcall(function()
            return toolsdata:GetAsync(plr.UserId)
        end)

        if success and toolstable then
            for _ , eachtool in pairs(toolstable) do
                local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
                if tool then
                    local newtool_folder = tool:Clone()
                    local newtool_back = tool:Clone()
                    newtool_folder.Parent = tools_folder
                    newtool_back.Parent = Backpack                
                end
            end
        end
    end
    
end)

game.Players.PlayerRemoving:Connect(function(plr_leave)
    local tools = {}
    local tools_folder = plr_leave:FindFirstChild("Tools_Folder")
    for _, eachtool in pairs(tools_folder:GetChildren()) do 
        table.insert(tools , eachtool.Name)
    end

    local success , error = pcall(function()
        return toolsdata:SetAsync(plr_leave.UserId , tools)
    end)

    if not success then
        warn(plr_leave.Name .."Didn't save tools data: ".. error)
    end
end)
#

this work so yeah i need to wait charcter to load

honest dove
#

finallz

#

only needed us 241 messages to figure out 🙏

thin dragon
#

because you're waiting for it already

raw mantle
#

more safety

honest dove
raw mantle
thin dragon
raw mantle
raw mantle
thin dragon
#

oh and you spelt character wrong

raw mantle
#

but finnaly it worked

#

tysm guys

#

But

#

this code will work fine like its ? /10 ?

thin dragon
honest dove
#

fine for saving tools

#

bad for expanding

raw mantle
raw mantle
honest dove
#

profile service is just a more secure method but it also uses DataStoreService so if you use DataStoreService correct it doesnt really make a diffrence

raw mantle
#

it needs module

#

and i understand way of module but when i use it my brain start to get errors

honest dove
#

its pretty simple

raw mantle
honest dove
#

it was also confusing at the start for me but its really helpful for making things organized

honest dove
raw mantle
honest dove
#

nah with your knowledge you should be able to learn them

thin dragon
raw mantle
#

like i cant read 3 pages to understand it

thin dragon
raw mantle
#

ok

honest dove
#

and thats what i meant with expandable

#

this is what i use as my datastore

#

it doesnt work for tools tho might have to rewrite that

#

or arrays at all actually

raw mantle
#

yeah but bro its very goood

vast veldtBOT
#

studio** You are now Level 19! **studio

raw mantle
#

like i cant understand the script lol

honest dove
#

yeah the loops are pretty nested

#

but it just saves/loads data from the dataTree thats all

raw mantle
#

u use module script ?

honest dove
#

yeah these are both module scripts

raw mantle
#

bec this i cant understand it

honest dove
#
local SSS = game:GetService("ServerScriptService")
local MDLS = SSS:WaitForChild("Modules")

local dataService = require(MDLS.dataService)  

PLRS.PlayerAdded:Connect(function(plr)
    dataService:_initPlayer(plr)
end)

PLRS.PlayerRemoving:Connect(function(plr)
    dataService.dataSave(plr)
end)

game:BindToClose(function()
    for i,v in pairs(game.Players:GetPlayers()) do
        dataService.dataSave(v)
    end
end)

task.spawn(function()
    while true do
        task.wait(60)
        for _, plr in pairs(game.Players:GetPlayers()) do
            dataService.dataSave(plr)
        end
    end
end)
#

i would run them like this

raw mantle
#
local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
local runservice = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(plr)
    local waittime = 0
    local Character = plr.Character or plr.CharacterAdded:Wait()
    if Character then
        local tools_folder = plr:WaitForChild("Tools_Folder")
        local Backpack = plr:WaitForChild("Backpack")
        local success , toolstable = pcall(function()
            return toolsdata:GetAsync(plr.UserId)
        end)

        if success and toolstable then
            for _ , eachtool in pairs(toolstable) do
                local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
                if tool then
                    local newtool_folder = tool:Clone()
                    local newtool_back = tool:Clone()
                    newtool_folder.Parent = tools_folder
                    newtool_back.Parent = Backpack                
                end
            end
        end
        local tools = {}

        runservice.Heartbeat:Connect(function(deltatime)
            waittime += deltatime
            if waittime >= 60*5 then
                waittime = 0
                if plr.Parent ~= nil then
                    for _, eachtool in pairs(tools_folder:GetChildren()) do 
                        table.insert(tools , eachtool.Name)
                    end

                    local success , error = pcall(function()
                        return toolsdata:SetAsync(plr.UserId , tools)
                    end)

                    if not success then
                        warn(plr.Name .."Didn't save tools data: ".. error)
                    end
                end
                
            end
        end)
        
        
    end
    
end)
#

this will work fine right ?

#

oh i forgot to add disconnct

vast veldtBOT
#

studio** You are now Level 7! **studio

raw mantle
honest dove
raw mantle
#

but if i want to make it like 7 , 8 i think that i will do local min = 1

royal canyon
#

Why have I been @ed 4 times?

honest dove
#

we figured it out mb 😭

raw mantle
#
local datastoreservice = game:GetService("DataStoreService")
local toolsdata = datastoreservice:GetDataStore("toolsdata")
local runservice = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(plr)
    local waittime = 0
    local Character = plr.Character or plr.CharacterAdded:Wait()
    if Character then
        local tools_folder = plr:WaitForChild("Tools_Folder")
        local Backpack = plr:WaitForChild("Backpack")
        local success , toolstable = pcall(function()
            return toolsdata:GetAsync(plr.UserId)
        end)

        if success and toolstable then
            for _ , eachtool in pairs(toolstable) do
                local tool = game.ServerStorage.Folder:FindFirstChild(eachtool)
                if tool then
                    local newtool_folder = tool:Clone()
                    local newtool_back = tool:Clone()
                    newtool_folder.Parent = tools_folder
                    newtool_back.Parent = Backpack                
                end
            end
        end
        local tools = {}
        local connect
        connect = runservice.Heartbeat:Connect(function(deltatime)
            waittime += deltatime
            if waittime >= 60*5 then
                waittime = 0
                if plr.Parent ~= nil then
                    for _, eachtool in pairs(tools_folder:GetChildren()) do 
                        table.insert(tools , eachtool.Name)
                    end

                    local success , error = pcall(function()
                        return toolsdata:SetAsync(plr.UserId , tools)
                    end)

                    if not success then
                        warn(plr.Name .."Didn't save tools data: ".. error)
                    end
                else
                    connect.Disconnect()
                end
            end
        end)
    end
    
end)
#

this will work fine ?

royal canyon
raw mantle
#

wtf

honest dove
#

i would recommend you to watch the video

#

the stuff ziffix sends is actually pretty useful

#

alr fake_name1 gl on your scripting journy ima go now

raw mantle
raw mantle
#

@royal canyon ty alot this video make me learn alot of things

raw mantle
honest dove
#
function dataService:_initPlayer(plr)
    local data = dataService:_loadPlayerData(plr)
    
    for i, folder in dataTree.Folders do
        dataService:_createFolder(plr, folder, data)
    end
end

function dataService:_loadPlayerData(plr)
    if not dataTree.DataStoreName then return end
    
    local success, result = pcall(function()
        DSS:GetDataStore(dataTree.DataStoreName):GetAsync(plr.UserId)
    end)
    
    return success and result or {}
end

function dataService:_createFolder(plr, folderDef, data)
    local newFolder = Instance.new("Folder")
    newFolder.Name = folderDef.Name
    newFolder.Parent = plr
    
    for i, value in folderDef.Values do
        dataService:_createValue(value, newFolder, data)
    end
end

function dataService:_createValue(valueDef, newFolder, data)
    local value = Instance.new(valueDef.Instance)
    value.Name = valueDef.Name
    
    if data and valueDef.Save and data[valueDef.Name] then
        value.Value = data[valueDef.Name]
    else
        value.Value = valueDef.StartValue
    end
    
    value.Parent = newFolder
end

i already unnested the load section

raw mantle
#

broo dont make me watch those module script

#

ohh i have really really bad thing

#

my memory usage is 2409MB Y_Y @honest dove

honest dove
#

its cause of studio dw

#

I also got 1600mb

#

idk why u got 800mb more tho 💀

raw mantle
honest dove
raw mantle
#

just fps and when plr buy toon then gives item all those 2409mb

honest dove
#

o

raw mantle
#

there is way i can show u my game ?

raw mantle
#

i will join roblox normall

honest dove
#

screenshare or invite me

#

or make it puplic and send me the link yea

raw mantle
#

i dm ?

honest dove
#

z

#

y

#

go for it