I think this is a step in the right direction however I have been having this issue and cant seem to get around it. Similar to other games my game has a “Met the owner” badge type thing. In my game it gives you a noob (the noob’s name is “alexNoob”) and as the owner I get given this as soon as i join.
Everything has been modified a bit to fit my code:
function LoadData(player)
local noobs = player.noobs:GetChildren()
--// Get data
local success, Data = pcall(DataStore.GetAsync, DataStore, player.UserId)
if not success then warn(Data) Data = {} end
--// Load
for _, noob in pairs(Data or {}) do
print(noob)
print(Data)
end
print("Loaded " .. player.Name .. "'s data")
end
function SaveData(player)
--// Get table
local ToSave = {}
for _, V in pairs(player.noobs:GetChildren()) do
if V:IsA("BoolValue") and V.Value then
table.insert(ToSave, V.Name)
end
end
--// Save data
local success, err = pcall(DataStore.SetAsync, DataStore, player.UserId, ToSave)
if not success then warn(err) end
print("Saved " .. player.Name .. "'s data")
end
Players.PlayerAdded:Connect(function(plr)
local progress = Instance.new("Folder",plr)
progress.Name = "NoobProgress"
local thawIce= Instance.new("BoolValue",progress)
thawIce.Value = false
thawIce.Name = "ThawIce"
local onFire = Instance.new("BoolValue", progress)
onFire.Value = false
onFire.Name = "OnFire"
local noobs = Instance.new("Folder",plr)
noobs.Name = "noobs"
local noobNoob = Instance.new("BoolValue",noobs)
noobNoob.Name = "noobNoob"
noobNoob.Value = false
local alexNoob = Instance.new("BoolValue",noobs)
alexNoob.Name = "alexNoob"
alexNoob.Value = false
local coolNoob = Instance.new("BoolValue",noobs)
coolNoob.Name = "coolNoob"
coolNoob.Value = false
local dapperNoob = Instance.new("BoolValue",noobs)
dapperNoob.Name = "dapperNoob"
dapperNoob.Value = false
local fireNoob = Instance.new("BoolValue",noobs)
fireNoob.Name = "fireNoob"
fireNoob.Value = false
local ghostNoob = Instance.new("BoolValue",noobs)
ghostNoob.Name = "ghostNoob"
ghostNoob.Value = false
local greenscreenNoob = Instance.new("BoolValue",noobs)
greenscreenNoob.Name = "greenscreenNoob"
greenscreenNoob.Value = false
local groupNoob = Instance.new("BoolValue",noobs)
groupNoob.Name = "groupNoob"
groupNoob.Value = false
local iceNoob = Instance.new("BoolValue",noobs)
iceNoob.Name = "iceNoob"
iceNoob.Value = false
local iceyNoob = Instance.new("BoolValue",noobs)
iceyNoob.Name = "iceyNoob"
iceyNoob.Value = false
local invertedNoob = Instance.new("BoolValue",noobs)
invertedNoob.Name = "invertedNoob"
invertedNoob.Value = false
local rainbowNoob = Instance.new("BoolValue",noobs)
rainbowNoob.Name = "rainbowNoob"
rainbowNoob.Value = false
local treeNoob = Instance.new("BoolValue",noobs)
treeNoob.Name = "treeNoob"
treeNoob.Value = false
LoadData(plr)
end)
Players.PlayerRemoving:Connect(function(plr)
SaveData(plr)
end)
I have no idea where it went wrong. I dont know if its the loading or the saving but when I join console is printed with this message.
16:45:04.952 ▼ {
[1] = "alexNoob"
} - Server - NoobHandler:17
16:45:04.952 Loaded alexwarrior317's data - Server - NoobHandler:20
I have no idea why the data table it is getting alexNoob and not any other data. Ive check and it also does not update the alexNoob boolvalue (untill the part of the script that handles the “met the owner noob” runs) or any other noob.
Does anyone know why this might be happening?
Thanks,