Invalid Argument#3 (string expected,got nil) problem

Hello

  1. I am working in a pet system, and all works great, but the save system no

2.In the output panel appear this:

  1. I already see for mispelled word
    Here is the part of script is the problem:
local equippedPetData = PetDataStore:GetAsync(player.UserId.."-equippedPet")
	
	if equippedPet then
		equippedPet.Value = equippedPetData
		game.ReplicatedStorage.SetEquippedPet:FireClient(player,equippedPetData)
	end
	
end)

Thanks for read! :smiley:

That means that you are not sending an expected third argument to the client. That #3 argument is supposed to be a string.

So how is supposed to be? :thinking:

Could you give us the source where you a connecting the RemoteEvent’s event?

Sorry, but You mean entire script?

game.ReplicatedStorage.SetEquippedPet:FireClient(player,equippedPetData)

you do not need the player argument for the client script that receives this event call because it is automatically selected who fired it, so basically replace it with this

game.ReplicatedStorage.SetEquippedPet:FireClient(equippedPetData)

anyways which exact codeline is the one being errored in the main script?

equippedPet.Value = equippedPetData

Is exactly this

you can try use “tostring(equippedPetData)” which turns it to a string value or something

1 Like
local equippedPetData = PetDataStore:GetAsync(player.UserId.."-equippedPet")
	
	if equippedPet then
		tostring(equippedPetData)
		game.ReplicatedStorage.SetEquippedPet:FireClient(player,equippedPetData)
	end
	
end)

Like this?

not exactly, like this “equippedPet.Value = tostring(equippedPetData)”

2021-01-05 (6)
Now the output change

yeah, i made a mistake, you can revert that back to game.ReplicatedStorage.SetEquippedPet:FireClient(player,equippedPetData)

The pet still without saving and problem moves to another script :thinking:

if scrollingFrame:FindFirstChild(petName) then

you need a 3rd argument on whatever is on the line which is generating the error

can you specify what kind of data are you loading here?
local equippedPetData = PetDataStore:GetAsync(player.UserId.."-equippedPet")
Is it a solid string or a table?

There what is loading Is a table

so as far as I know the reason that your remote event isn’t working is that tostring() function can’t convert a table into a string and it will return nil or something like Table:565x456554646

nice one! I had a similar issue and this fixed my problem. Thanks @reygenne1

1 Like