"Buy a Hint" System

Hello, I would like to make it so that players can buy (using an item, developer products ID) an in-game hint by clicking on a box, it offers him to buy the hint, once buy, the message displayed until the player closes it by himself.
I’m a beginner and couldn’t find any help on this. THANKS !

1 Like

Bro you can’t just ask for full on scripts, try learning how to make dev products work and all

1 Like
  1. Create a GUI for Buying Hints: Create a User Interface (UI) that displays the hint purchase option when players click on a box. You can use tools like the StarterPack to create the UI elements you need, such as a button to buy the hint.
  2. Implement Purchase Logic: When the player clicks on the button to buy the hint, you should handle the purchase logic. You can use the MarketplaceService to prompt the player for the purchase. Here’s a basic example:

luaCopy code

local MarketplaceService = game:GetService("MarketplaceService")

local hintProductId = YOUR_HINT_PRODUCT_ID -- Replace with the actual product ID

local function BuyHint(player)
    local success, errorMessage = pcall(function()
        local purchaseResult = MarketplaceService:PromptProductPurchase(player, hintProductId)
        if purchaseResult == Enum.ProductPurchaseDecision.PurchaseGranted then
            -- Grant the hint to the player and show a message
            -- You can store the player's purchase state in a data store
            -- or some other persistent storage method
            -- Then show a message on the player's screen
            -- You can use a hint GUI element to display the hint message
        elseif purchaseResult == Enum.ProductPurchaseDecision.NotProcessedYet then
            -- Handle this case if necessary
        else
            -- Handle failed purchase
        end
    end)
    if not success then
        warn("Error while processing purchase:", errorMessage)
    end
end

-- Connect the BuyHint function to the button's Click event
button.MouseButton1Click:Connect(function()
    local player = game.Players:GetPlayerFromCharacter(button.Parent.Parent)
    if player then
        BuyHint(player)
    end
end)
  1. Display Hint Message: After the player has successfully purchased the hint, you can display the hint message on their screen. You can use GUI elements like BillboardGui or a custom GUI in a corner of the screen to show the hint.
  2. Save Player’s Purchase State: You’ll need to save the player’s purchase state so that they don’t have to buy the hint again. You can use a data store (like DataStoreService) to save and retrieve the player’s purchase state.

Remember to replace YOUR_HINT_PRODUCT_ID with the actual product ID of the hint in your developer products. Also, customize the UI elements, hint message display, and data storage to fit your game’s design.

Lastly, make sure to thoroughly test your implementation to ensure it works as expected and handles different scenarios, such as successful purchases, failed purchases, and player data persistence.

1 Like

if he wants help he gets help.

1 Like

and you can not call me “bro” because I am in no way your family, cordially.

Thank you very much I will try all that! thank you for the help and your kindness.

no problem man i am here to help anyone btw try watching dev videos to learn more about coding next time you can write it yourself maybe

1 Like

btw this topic is now done if you mark my message as solution the topic is done

Everyone uses it for anyone, that’s just the internet

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.