Will this code work?

So I’m making a gamepass where if you buy it, you get a tower except I can’t test this because I already own it automatically, will this work?


MarketService.PromptGamePassPurchaseFinished:Connect(function(playerWhoPurchased, id, wasPurchased)
	if wasPurchased == true and playerWhoPurchased and data[playerWhoPurchased.UserId] then
		if id == largeScientistID then
			table.insert(data[playerWhoPurchased.UserId].OwnedTowers, "Large Scientist Cameraman")
			errorEvent:FireClient(playerWhoPurchased,"Success","Thanks for your support!")
		end
	end
end)

It should work, I don’t see any mistakes in your code.
Still, try to do some tests if you can.

How could I test this out though?

A prompt should still appear. This event fires whenever the prompt closes.
Print all the data that has been sent from the event, and compare it manually.
Like if id equals to largeScientistID, etc.

Alright I’m just gonna hope it works, thank you