hi recently started to create my own game and there was a difficulty in the store I am asking for help 2 times already because I do not have special information in the field of scripting here is an error
ServerScriptService.LastEquipped:11: invalid argument #3 (string expected, got table)
here is the script itself
local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("Buy10")
game.ReplicatedStorage.GameClient.Events.RemoteEvent.PlayerLoaded.OnServerEvent:Connect(function(player)
local equippedlast = Instance.new("StringValue")
equippedlast.Name = "Equipped"
local save = ds:GetAsync(player.UserId)
if save then
equippedlast.Value = save
else
local name
for i, tool in pairs(game.ServerStorage.Tools:GetChildren()) do
if tool:FindFirstChild("ItemNumber") then
if tool.ItemNumber.Value == 1 then
name = tool.Name
end
end
end
equippedlast.Value = name
end
equippedlast.Parent = player
local clone = game.ServerStorage.Tools:FindFirstChild(equippedlast.Value):Clone()
clone.Parent = player:WaitForChild("Backpack")
end)
game.Players.PlayerRemoving:Connect(function(player)
ds:SetAsync(player.UserId, player.Equipped.Value)
end)

3 comments
hello, could you explain where to write where StringValue is?
so your saying where StringValue is? as i was saying, replace the save at Line 11 with save['variablename]
worked but got an error at line 27 ServerScriptService.LastEquipped:27: attempt to index nil with 'Clone'