I’m trying to save 3 boolean values using DataStore when the player leaves and have the values load when the player joins. So far, 2 out of the 3 values work but the last one won’t load when the player joins. Using Print statements I’ve narrowed it down to one portion of the code.
Code:
game:GetService("Players").PlayerAdded:Connect(function(plr)
local ToolsEquiped = Instance.new("Folder")
ToolsEquiped.Parent = plr
ToolsEquiped.Name = "ToolsEquiped"
local SwordEquiped = Instance.new("BoolValue")
SwordEquiped.Name = "SwordEquiped"
SwordEquiped.Parent = ToolsEquiped
local JumpCoilEquiped = Instance.new("BoolValue")
JumpCoilEquiped.Name = "JumpCoilEquiped"
JumpCoilEquiped.Parent = ToolsEquiped
local SpeedCoilEquiped = Instance.new("BoolValue")
SpeedCoilEquiped.Name = "SpeedCoilEquiped"
SpeedCoilEquiped.Parent = ToolsEquiped
local Key = plr.UserId.."-Tools"
local toolsData = {
["SwordEquipped"] = false,
["JumpCoilEquiped"] = false,
["SpeedCoilEquiped"] = false
}
local success, errorMessage = pcall(function()
toolsData = dropperData:GetAsync(Key)
end)
if not success then
warn(errorMessage)
end
if toolsData then
SwordEquiped.Value = toolsData.SwordEquiped
print(toolsData)
JumpCoilEquiped.Value = toolsData.JumpCoilEquiped
print(JumpCoilEquiped.Value)
SpeedCoilEquiped.Value = toolsData.SpeedCoilEquiped
end
if SwordEquiped.Value == true then
local backpackClone = Sword:Clone()
local starterGearClone = Sword:Clone()
backpackClone.Parent = plr.Backpack
starterGearClone.Parent = plr.StarterGear
plr.ToolsEquiped:WaitForChild("SwordEquiped").Value = true
end
if SpeedCoilEquiped.Value == true then
local backpackClone = speedCoil:Clone()
local starterGearClone = speedCoil:Clone()
backpackClone.Parent = plr.Backpack
starterGearClone.Parent = plr.StarterGear
plr.ToolsEquiped:WaitForChild("SpeedCoilEquiped").Value = true
end
if JumpCoilEquiped.Value == true then
local backpackClone = jumpCoil:Clone()
local starterGearClone = jumpCoil:Clone()
backpackClone.Parent = plr.Backpack
starterGearClone.Parent = plr.StarterGear
plr.ToolsEquiped:WaitForChild("JumpCoilEquiped").Value = true
end
end)
Section where I think problem starts:
if toolsData then
SwordEquiped.Value = toolsData.SwordEquiped
print(toolsData)
JumpCoilEquiped.Value = toolsData.JumpCoilEquiped
print(JumpCoilEquiped.Value)
SpeedCoilEquiped.Value = toolsData.SpeedCoilEquiped
end
Output:
19:57:31.996 ▼ {
["JumpCoilEquipped"] = true,
["SpeedCoilEquiped"] = true,
["SwordEquiped"] = true
} - Server - DropperDataScript:109
19:57:31.996 false - Server - DropperDataScript:111```