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

Why are the points not saving properly?

Asked by 4 years ago

Im trying to save the players stat points and it works nice, but for some reason its not working for melee everytime, here is the script:

01local DataStore = game:GetService("DataStoreService"):GetDataStore("StatsDataStore")
02game.Players.PlayerAdded:Connect(function(player)
03    local MeleeName = "MeleeP"
04    local folder = player:WaitForChild("Data")
05    local MeleeP = player:FindFirstChild("Data"):WaitForChild("MeleeP")
06    local ID2 = MeleeName.."-"..player.UserId
07    local savedData = nil
08    pcall(function()
09        savedData = DataStore:GetAsync(ID2)
10    end)
11 
12        if savedData ~= nil then
13        MeleeP.Value = savedData
14        print("Data loaded")
15    else
View all 37 lines...

Thank you!

0
Well first of all when you do find first child, it either finds it or it returns nil. That’s important to know. Wait for child waits for it indefinitely. Now you already said folder = the data part so this is just a tip.. when you declare the variable MeleeP you can say MeleeP = folder. Blah. That wasn’t the issue but it irked me. SethHeinzman 284 — 4y
0
i alredy solved it btw and thanks for the advice but a wait(4) after the player added event has the same effect valledestroy 54 — 4y
0
i also know that i could change that but im to lazy for that valledestroy 54 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Already Solved!

Ad

Answer this question