I store 7 values in a datastore for my game. Their names are:
- Pyrokinesis
- Telekinesis
- Concilium
- Descensum
- Divination
- Vitalum Vitalis
- Transmutation
Whenever a player joins the game, I call the datastore with GetDataStore() and then put that data into a table. I then use if
statements to check if each value is present, and if it is, I add a BoolValue
to the player.
This works fine, aside from ONE value, Transmutation. I have it when I leave the game, and it’s saved in the datastore, but when I rejoin, it’s not even registering that the value is there so it isn’t adding it to my player.
Data Saving Script:
local WondersData = datastoreService:GetDataStore("DSJGDAOPUGODP") -- changed the actual datastore for obvious reasons
game.Players.PlayerRemoving:Connect(function(player)
local plrWonders = {}
if player:FindFirstChild("Bloodline") and player:FindFirstChild("Bloodline").Value ~= nil then
BloodlineData:SetAsync(player.UserId, player.Bloodline.Value)
print("saved bloodline")
end
if player:FindFirstChild("Species") and player:FindFirstChild("Species").Value ~= nil then
SpeciesData:SetAsync(player.UserId, player.Species.Value)
print("saved species")
end
if player.Species.Value == "Witch" then
if player:FindFirstChild("Pyrokinesis") then
table.insert(plrWonders, "Pyrokinesis")
print("pyro")
end
if player:FindFirstChild("Telekinesis") then
table.insert(plrWonders, "Telekinesis")
print("tk")
end
if player:FindFirstChild("Divination") then
table.insert(plrWonders, "Divination")
print("div")
end
if player:FindFirstChild("Descensum") then
table.insert(plrWonders, "Descensum")
print("desc")
end
if player:FindFirstChild("Concilium") then
table.insert(plrWonders, "Concilium")
print("conc")
end
if player:FindFirstChild("Vitalum Vitalis") then
table.insert(plrWonders, "Vitalum Vitalis")
print("vit")
end
if player:FindFirstChild("Transmutation") then
table.insert(plrWonders, "Transmutation")
print("tp")
end
WondersData:SetAsync(player.UserId, plrWonders)
print("saved wonders")
end
Data Checking & Value Creation Script: (relevant parts)
print("loading wonders for "..player.Name)
local wonders = WondersData:GetAsync(player.UserId) or nil
if table.find(wonders, "Pyrokinesis") then
print("pyro found for "..player.Name)
pyro = true
local pyroV = Instance.new("BoolValue", player)
pyroV.Name = "Pyrokinesis"
pyroV.Value = true
print("pyro added to "..player.Name)
w = true
for _,v in pairs(game:GetService("ServerStorage"):FindFirstChild("ClientPowers"):FindFirstChild("Pyrokinesis"):GetChildren()) do
if not player.Character.PlayerConfig.Abilities:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character:WaitForChild("PlayerConfig"):WaitForChild("Abilities")
end
end
else
pyro = false
end
if table.find(wonders, "Telekinesis") then
print("tk found for "..player.Name)
tk = true
local tkV = Instance.new("BoolValue", player)
tkV.Name = "Telekinesis"
tkV.Value = true
print("tk added to "..player.Name)
local sc = script.TKHighlight:Clone()
sc.Parent = player.Character.PlayerConfig.Basics
w = true
for _,v in pairs(game:GetService("ServerStorage"):FindFirstChild("ClientPowers"):FindFirstChild("Telekinesis"):GetChildren()) do
if not player.Character.PlayerConfig.Abilities:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character:WaitForChild("PlayerConfig"):WaitForChild("Abilities")
end
end
else
tk = false
end
if table.find(wonders, "Divination") then
print("div found for "..player.Name)
div = true
local divV = Instance.new("BoolValue", player)
divV.Name = "Divination"
divV.Value = true
print("div added to "..player.Name)
w = true
for _,v in pairs(game:GetService("ServerStorage"):FindFirstChild("ClientPowers"):FindFirstChild("Divination"):GetChildren()) do
if not player.Character.PlayerConfig.Abilities:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character:WaitForChild("PlayerConfig"):WaitForChild("Abilities")
end
end
else
div = false
end
if table.find(wonders, "Descensum") then
print("desc found for "..player.Name)
desc = true
local descV = Instance.new("BoolValue", player)
descV.Name = "Descensum"
descV.Value = true
print("desc added to "..player.Name)
w = true
for _,v in pairs(game:GetService("ServerStorage"):FindFirstChild("ClientPowers"):FindFirstChild("Descensum"):GetChildren()) do
if not player.Character.PlayerConfig.Abilities:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character:WaitForChild("PlayerConfig"):WaitForChild("Abilities")
end
end
else
desc = false
end
if table.find(wonders, "Concilium") then
print("conc found for "..player.Name)
conc = true
local concV = Instance.new("BoolValue", player)
concV.Name = "Concilium"
concV.Value = true
print("conc added to "..player.Name)
w = true
for _,v in pairs(game:GetService("ServerStorage"):FindFirstChild("ClientPowers"):FindFirstChild("Concilium"):GetChildren()) do
if not player.Character.PlayerConfig.Abilities:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character:WaitForChild("PlayerConfig"):WaitForChild("Abilities")
end
end
else
conc = false
end
if table.find(wonders, "Vitalum Vitalis") then
print("vitalum found for "..player.Name)
vitalum = true
local vitalumV = Instance.new("BoolValue", player)
vitalumV.Name = "Vitalum Vitalis"
vitalumV.Value = true
print("vitalum added to "..player.Name)
w = true
for _,v in pairs(game:GetService("ServerStorage"):FindFirstChild("ClientPowers"):FindFirstChild("VitalumVitalis"):GetChildren()) do
if not player.Character.PlayerConfig.Abilities:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character:WaitForChild("PlayerConfig"):WaitForChild("Abilities")
end
end
else
vitalum = false
end
if table.find(wonders, "Transmutation") then
print("tp found for "..player.Name)
tp = true
local tpV = Instance.new("BoolValue", player)
tpV.Name = "Transmutation"
tpV.Value = true
print("tp added to "..player.Name)
w = true
for _,v in pairs(game:GetService("ServerStorage"):FindFirstChild("ClientPowers"):FindFirstChild("Transmutation"):GetChildren()) do
if not player.Character.PlayerConfig.Abilities:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character:WaitForChild("PlayerConfig"):WaitForChild("Abilities")
end
end
else
tp = false
end
print("loaded wonders for "..player.Name)
end
Output when I leave the game, proving it saved the values:
Output when rejoining, every value is detected except Transmutation.