I serious need help with a script im making!

I am making a game which lets you purchase catelog items by typing in the asset ID in a box. I have the script for the promt which brings up the purchase prompt but how do I make it trigger when you press “purchase” after typing in an asset id??
This is the script that brings up a purchase prompt for items:

  1. – Services
  2. local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
  3. local MarketplaceService = game:GetService(“MarketplaceService”)
  • – Setup RemoteEvent in ReplicatedStorage
  1. local promptPurchaseEvent = Instance.new(“RemoteEvent”)
  2. promptPurchaseEvent.Name = “PromptPurchaseEvent”
  3. promptPurchaseEvent.Parent = ReplicatedStorage
  • – Listen for the RemoteEvent to fire from a Client and then trigger the purchase prompt
  1. promptPurchaseEvent.OnServerEvent:Connect(function(player, id)
  2. MarketplaceService:PromptPurchase(player, id)
  3. end)
    How do I make it trigger when an asset ID is put into the box?

whenever u put something in the GUI box its text will be changed lemme give u an example

if TextBox.Text == "E" then
 print("E")
end

so that mean here is how your script must be:

 -- Services
 local ReplicatedStorage = game:GetService("ReplicatedStorage")
 local MarketplaceService = game:GetService("MarketplaceService")

 -- Setup RemoteEvent in ReplicatedStorage

    local promptPurchaseEvent = Instance.new("RemoteEvent")
    promptPurchaseEvent.Name = "PromptPurchaseEvent"
    promptPurchaseEvent.Parent = ReplicatedStorage

Button.Activated:connect(function() --- i dont know if you are using a button
local id = TextBox.Text 
promptPurchaseEvent:FireServer(id)
end)

-- for this u have to put a script in the server storage and put these in if u didnt do it.
 local promptPurchaseEvent = game.ReplicatedStorage.PromptPurchaseEvent
  local MarketplaceService = game:GetService("MarketplaceService")
 promptPurchaseEvent.OnServerEvent:Connect(function(player, id)
 MarketplaceService:PromptPurchase(player, id)
 end)

its mostly recomended to put the remote yourself and not doing instance.new in a script

1 Like