Hey guys, I have been asking lot of question but I'm trying to make a save script but there was a error that I don't know how to fix

Here's the output: 14:08:14.366 - ServerScriptService.SaveScript2:9: attempt to index local 'slot1taken' (a string value) 14:08:14.368 - Stack Begin 14:08:14.370 - Script 'ServerScriptService.SaveScript2', Line 9 14:08:14.372 - Stack End Here's the error; 14:08:14.366 - ServerScriptService.SaveScript2:9: attempt to index local 'slot1taken' (a string value)

Some Info: I put the script inside ServerScriptService, should I move it?

Here's the code;

local DataStore = game:GetService("DataStoreService"):GetDataStore("Slot1Taken")
local DataStore2 = game:GetService("DataStoreService"):GetDataStore("CurrentImage")
local DataStore3 = game:GetService("DataStoreService"):GetDataStore("NumberAmount")

game.Players.PlayerAdded:connect(function(plr)
	local PlayerKey = "user_" .. plr.userId
	
	local slot1taken = plr:WaitForChild("Slot1Taken").Value
	slot1taken.Value = DataStore:GetAsync(PlayerKey)
	
	local slot1currentimage = plr.PlayerGui.MenuGui.InventoryMain.InventoryFrame.InventoryBackground.ElementSlot1.ElementImage:WaitForChild("CurrentImage").Value
	slot1currentimage.Value = DataStore2:GetAsync(PlayerKey)
	
	local slot1amount = plr.PlayerGui.MenuGui.InventoryMain.InventoryFrame.InventoryBackground.ElementSlot1.ElementImage.Amount:WaitForChild("NumberAmount").Value
	slot1amount.Value = DataStore3:GetAsync(PlayerKey)
end)

If you find any other errors then please help and fix them, also if you would, please read the code and make it more easier or debug it for me, also explain what I did wrong. The saving doesn't work either.

Thank you for trying to help.

2 comments

1

You're using .Value twice, Line 8 is where you're getting the Slot1Taken's value, line 9 you try to take that value and get its value which cannot be done. Recommendation, just remove .Value from line 8.

0

Ok thanks