"value of type nil cannot be converted to a number" Error

Try printing it right after you call createSession

Still didn’t get anything, i think the issue would be the createSession function.

Could you show me your player in-game from the explorer?

“Rep.” is not “Reputation”. There is likely no “Reputation” key in your data dictionary, since you use v.Name (the ValueObject instance Name) as the table key.

3 Likes

Screenshot 2024-04-04 185123

Maybe the period in the name Rep. is causing an issue.

A period usually represents a directory change. Maybe it is throwing off the code.

Try changing it to Reputation just to see if it fixes the issue.

I changed Rep. into Rep, but now the error is just appearing again:

	if data then
		print("Data found for this player, setting...")

		print("Cash.Value =", Cash.Value)
		print("Reputation.Value =", Reputation.Value)
		print("Wanted.Value =", Wanted.Value)

		Cash.Value = data["Cash"]
		Reputation.Value = data["Rep"]
		Wanted.Value = data["Wanted"]
	else
		print("No data found for this player.")
		Cash.Value = default_Set.Cash
	end
end

You are using the NumberValue’s name as the key in the table, you’d have to do data[“Rep.”]

Well yeah, because you wrote the key to the datastore as “Rep.” (with a period) so trying to fetch it with “Rep” (no period) is no better than “Reputation”; it’s still not a match.

I think this would have fixed it, so I’m assuming the period in Rep was indeed the issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.