Attempt to call a RBXScriptSignal value

So I want by clicking on the donate button, the player could donate and make a free (for donation) rebirth. But for some reason, this happens:

Why? Here’s the script, note the donateRebirth function

local player = game:GetService("Players").LocalPlayer
local ld = player:WaitForChild("leaderstats")
local damage = ld.Damage
local rebirth = ld.Rebirth

local main = script.Parent
local button = main.makeRebirth
local donateButton = main.DonateRebirth

local MPS = game:GetService("MarketplaceService")
local devproductId = main.devproductId.Value

local function makeRebirth()
	if damage.Value >= main.forRebirth.Value then
		game:GetService("SoundService").Click:Play()
		
		rebirth.Value += 1
		damage.Value = damage.Value - main.forRebirth.Value
	end
end

local function donateRebirth()
	MPS.PromptProductPurchaseFinished(player, 1570916668)
	
	game:GetService("SoundService").Click:Play()

	rebirth.Value += 1
end


button.MouseButton1Click:Connect(makeRebirth)
button.TouchTap:Connect(makeRebirth)

donateButton.MouseButton1Click:Connect(donateRebirth)
donateButton.TouchTap:Connect(donateRebirth)

if anything, this is a locale script that is in the GUI

Again, this is what I want to do. The player donates and gets free rebits without spending power and so on. Again, he has to donate, and then if he wants he can donate and get a second rebirth. So this is not a gamepass and he can do this an infinite number of times

I’ll tell you right away that I read the documentation and did everything as it says, here:

But for some reason I still get this error

1 Like

MarketplaceService.PromptProductPurchaseFinished is an event, not a method (function)–hence, the error. Did you mean to call MarketplaceService:PromptProductPurchase()?

Also, shouldn’t you only change Rebirth’s Value if the player makes the donation?

2 Likes

Yes, I only need to change rebirth.Value, because in other scripts it all connects. Okay, if it’s an event, how do I do what I want?

1 Like
PromptPurchaseFinished:Connect(function(player, id, isPurchased)
      if (id == 1570916668) then
          print(player,id,isPurchased)
     end
end)
1 Like

Okay, I did this… but nothing happens, it just prints out this…

local function donateRebirth()
	print("1")
	MPS.PromptPurchaseFinished:Connect(function(player, id, isPurchased)
		print("2")
		if (id == 1570916668) then
			print(player,id,isPurchased)
		end
	end)
end

2 Likes

Why did you put it inside a function…
if your functions is getting called multiple times then it will cause memory leak.

1 Like