Trouble with having the same 'variable'

I’m having a very small issue when sending the ServerMessage.

The issue is when I FireAllClients. When I pass the Mutator it seems like the middle is getting the Mutator from the top one, and the bottom one is getting the middle and top Mutator.

productHandlers[1615053567] = function(localPlayer)
	workspace.Mutators.DoubleCoins.Value = true
	Mutator = workspace.Mutators.DoubleCoins
	ServerMessage:FireAllClients(localPlayer, Mutator)
end

productHandlers[1616661350] = function(localPlayer)
	workspace.Mutators.DoubleJump.Value = true
	Mutator = workspace.Mutators.DoubleJump
	ServerMessage:FireAllClients(localPlayer, Mutator)
end

productHandlers[1617799800] = function(localPlayer)
	workspace.Mutators.BunnyHop.Value = true
	Mutator = workspace.Mutators.BunnyHop
	ServerMessage:FireAllClients(localPlayer, Mutator)
end

here’s an image of the problem. 1 is the top, 2 is the middle, and 3 is the bottom.
image

Idk what’s going on here but I’ve tried few stuff a few stuff like putting Mutator in the function’s variables but that had no effect. I’ve also tried making them private with an underscore but I don’t know how to make it work.

productHandlers[1615053567] = function(localPlayer, Mutator)
	workspace.Mutators.DoubleCoins.Value = true
	Mutator = workspace.Mutators.DoubleCoins
	ServerMessage:FireAllClients(localPlayer, Mutator)
end

I know this is probably a super easy fix I’ve just never done this before so I don’t know where to look. Also note that I’ve got a local script and when OnClientEvent, it basically types a message in chat of what the player bought and who bought it.

any help is very appreciated

1 Like

I assume that this is a devproduct handler, right?
The devproduct functions will fire multiple times if the ProductPurchaseDecision is not returned.
At the end of the initial ProcessReceipt, look at returning

Enum.ProductPurchaseDecision.PurchaseGranted

and see if that addresses the issue


Also, You may want to set “Mutator” to a local variable, instead of a global variable.
(i.e. local Mutator = workspace.Mutators...)

Hi Sorry for the late reply but yes it’s a dev product handler. I found the main issue when I was purchasing the products I wasn’t returning the purchase as true… So then the purchase is never fully complete. But the code originally works. :sweat_smile:

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