Alright, I've been asking to a lot of people to help me to fix this bug or whatever it is. But none of their fixes worked. So I'm here to ask you again to help me.
So, I tried to write this script thanks to an Expert, but this didn't work though. Is it my fault? Is it script's fault? No idea. I've never tried to know about DataStore since I think it's pretty hard for me. This is the script:
local playeractive = false
local statsDS = game:GetService("DataStoreService"):GetDataStore("StoreName")
local prefix = "usr_"
game.Players.PlayerAdded:Connect(function(plr)
local points = plr:WaitForChild("Backpack").AvailablePoints
local strength = plr:WaitForChild("Backpack").Strength
-- load data in
local data = statsDS:GetAsync(prefix .. tostring(plr.UserId))
if data then
print("Data loaded for " .. prefix .. tostring(plr.UserId))
points.Value = data[1]
strength.Value = data[2]
end
points.Parent = plr
strength.Parent = plr
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = {
plr:WaitForChild("Backpack"):WaitForChild("Points").Value,
plr:WaitForChild("Backpack"):WaitForChild("Level").Value
}
-- pass a table to save
statsDS:SetAsync(prefix .. tostring(plr.UserId), data)
end)
I need seriously your help, I also cannot remove the values in the backpack since I need those values in other stuff that would take me too much time to modify everything. Please help.
