title: How to make the gui button click and give prompt for product purchase?
body: <p>The script is very messy due to multiple attempts of trying to fix it from various places and people, yet it led to square one each time...</p>
  <p><strong>Local script:</strong></p>
  <pre><code>local Cash500 = script.Parent 
  local A500 = script.Parent.A500
  local player = game.Players.LocalPlayer ReplicatedStorage = game:GetService(&quot;ReplicatedStorage&quot;)
  MPS = game:GetService(&quot;MarketplaceService&quot;)
  id = 3736929511
  local player = game.Players.LocalPlayer
  local remoteEvent = ReplicatedStorage:WaitForChild(&quot;RE500&quot;)
  
      --Enlarges size when mouse hovers
      script.Parent.MouseEnter:Connect(function(x, y)
          Cash500.Size = UDim2.new (0, 90, 0, 85)
          A500.Size = UDim2.new(0, 75, 0, 30)
      end)
      --Resets size on not hovering mouse after mouse hovered
      script.Parent.MouseLeave:Connect(function(x, y)
          Cash500.Size = UDim2.new (0, 75, 0, 70)
          A500.Size = UDim2.new(0, 60, 0, 15)
      end)
  
  --Purchase 500 money for 35 robux 
  --Fires remoteEvent when clicked- goes to RemoteEventController that gives money over
  Cash500.MouseButton1Click:Connect(function()
      MPS:PromptProductPurchase(player, id)
      remoteEvent:FireServer(&quot;RE500&quot;)
  end)
  </code></pre>
  <p><strong>Leaderstat Handler:</strong></p>
  <pre><code>game.Players.PlayerAdded:Connect(function(player)
  
      local leaderstats = Instance.new(&quot;Folder&quot;, player)
      leaderstats.Name = &quot;leaderstats&quot;
  
      local Money = Instance.new(&quot;IntValue&quot;, leaderstats)
      Money.Name = &quot;Money&quot;
      
      local Gems = Instance.new(&quot;IntValue&quot;, leaderstats)
      Gems.Name = &quot;Gems&quot;
  end)
  
  local function addTime(player)
      while true do 
          local RandomNumber = math.random(1,5)
          wait(3)
          player.leaderstats.Money.Value+=RandomNumber -- Same as Value=value+1 it is now- Value+=1
      end
  end
  
  game.Players.PlayerAdded:Connect(addTime)
  </code></pre>
  <p><strong>RemoteEvent Controller:</strong></p>
  <pre><code>local ReplicatedStorage = game:GetService(&quot;ReplicatedStorage&quot;)
  local MPS = game:GetService(&quot;MarketplaceService&quot;)
  local remoteEvent = ReplicatedStorage:WaitForChild(&quot;RE500&quot;)
  
  
  local function Additional500(player)
      print(player.Name .. &quot; fired the remote event&quot;)
      print(&quot;Updated! &lt;3&quot;)
  end
  
  MPS.ProcessReceipt = function(receiptInfo)
      print(&quot;OOOF&quot;)
      if receiptInfo.ProductId == 3736929511 then 
          print(&quot;Start!&quot;)
          local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
          player.leaderstats.Money.Value = player.leaderstats.Money.Value + 500
          print(&quot;Ended!&quot;)
          return Enum.ProductPurchaseDecision.PurchaseGranted
      end
  end
  
  remoteEvent.OnServerEvent:Connect(Additional500)
  </code></pre>
  <p>There are no error messages coming out of the output but this when you click it comes up:</p>
  <p><a href="https://i.stack.imgur.com/TagOC.png" rel="nofollow noreferrer">The Error message</a></p>
  <p>Anyone know what to do ? Thanks! :)</p>