Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

equip system doesn't work but i start game Value Don't create what is it? Help

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)

1 answer

save is a table, thats why it says string expected, got table. Print out the table, then do save['(write the name of the variable name your looking for here)'] instead of just save. Let me know if this doesnt work.

3 comments

0

hello, could you explain where to write where StringValue is?

0

so your saying where StringValue is? as i was saying, replace the save at Line 11 with save['variablename]

0

worked but got an error at line 27 ServerScriptService.LastEquipped:27: attempt to index nil with 'Clone'

This discussion is preserved as it was. New answers, comments, and votes are closed.