Price different on another account

I am having an issue as shown below, that on one account it will remove 3,500 which is the accurate price, while on the other account (my alt) it removes 3,072 which is not the accurate price. How can I fix this? Scripts are listed below

Alt account:
image
Owner of the game: (the real price)
image

The script that removes the price:

game.ReplicatedStorage.EggHatchingRemotes.HatchServer.OnServerInvoke = function(player, egg)
	local eggModel = workspace:FindFirstChild("Folders"):FindFirstChild("_EGGS"):FindFirstChild(egg.Name)
	local eggData = require(game.ReplicatedStorage:WaitForChild("Game"):WaitForChild("Eggs"):WaitForChild(egg.Name):WaitForChild(egg.Name))
	if eggModel ~= nil then
		local price = eggData["cost"]
		local currency = eggData["currency"]
		local numberPrice = tonumber(price)
		
		if player.leaderstats[currency].Value >= numberPrice then
			player.leaderstats[currency].Value = player.leaderstats[currency].Value - price
			local chosenPet = choosePet(egg)
			local val = Instance.new("StringValue")
			val.Name  = chosenPet
			val.Parent = player.Pets
			
--			print(chosenPet)
			return chosenPet
		else
			return "Cannot Afford"
		end
	end
end

And the ModuleScript that tells the price

return {
	hatchable = true, 
	disabled = false, 
	displayName = "Golden Basic Egg", 
	cost = 3500, 
	currency = "Money", 
	area = "Spawn", 
	areaRequired = false, 
	eggRequired = "", 
	isGolden = true, 
	model = script.Parent:WaitForChild("Egg")
};

If anyone knows how to fix this, it will be much appreciated!

1 Like

Can you show us the code that makes the popup showing the price? It may be an issue with that, as this looks like it’d work fine.

edit: I’m also confused why you’re using numberPrice and then price instead? They should both already be numerical.

I already know that it’s not the GUI That pops up because whenever I turn off abbreviations, you can tell that it doesn’t remove 3500. And it uses numberPrice because I am lazy to change it and it doesn’t really make a difference, or does it? Not sure.

It shouldn’t make a difference, but what do you mean by abbreviations? Is that part of the GUI code?

Why I want to see your GUI code is I suspect you’re gaining back some amount of currency just right before it calculates the difference (if this is what you’re doing)

Otherwise there’s no explanation for this occurring.

P.S: You can use ternary math operations for properties too! Try replacing:

player.leaderstats[currency].Value = player.leaderstats[currency].Value - price

with:

player.leaderstats[currency].Value -= price

Since this refrains from repeatedly indexing the Value property.

You should also put player.leaderstats[currency] into a variable but I’m not here to nag, I’m here to help.

image
By abbreviations, I mean this. (I gave myself a bunch of money so ignore that)

Ah. I see. That’s a massive number, anyways, I’m not sure then why this is occurring. Are there any output messages at all? Try printing their currency before and after they purchase it, and the “price” variable as well as “numberPrice” just for debugging purposes.


Whenever I hatch on the account, it does indeed print 3500, and money.

I was referring to the numerical currency of the player purchasing it, how about the alt?

Okay so I changed my price through the Command bar for my alt, and it now seems like it is charging 3500 instead of the 3072. Not sure how this happened? Maybe because of the large amount of money?

Very easily a possibility. You might want to look into using a “BigNum” library and not using the leaderstats for absolute data, instead opting for a cache of player’s data, or something like “ProfileService” (You can find it on the devforum with a search, my search isn’t working atm so I can’t get the link for you. Sorry.)

Alright, thank you! I appreciate all your help, I’ll see what I can do! :smile: