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:
– 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
– Listen for the RemoteEvent to fire from a Client and then trigger the purchase prompt
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