DataStore Not updating one value but updates others

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```

I’m not gonna go too into detail, but it’s just a simple spelling mistake. To fix this you can find and replace all. “Equiped” to “Equipped”

Open the script, press CTRL + F, and you should see this:
image

Your script should say there is more than 0 matches. All you have to do is select the second text box and press enter until it says 0 matches or code in your script stops getting highlighted in yellow.

1 Like

You have:
If toolsdata then,
If what

Wow, can’t believe I didn’t catch that. Thank you!