How to make an player if textbutton clicked in surface gui gives an free model

I need an script that if someone click ,they make the player buy an free model as clicking Take for FREE to buy Hd admin


I asked to AI but they didn’t found solution
Can you help me ,theres no free models with a script that lets you buy a free model :sob:

4 Likes

you’d first want to make a LocalScript in StarterPlayerScripts or StarterCharacterScripts

Once you have the script, just get the services “MarketplaceService” and “Players” (the players service will be handy later)

Now, if you want a button so that if you press it, it pops up with the prompt. To do that, you’d want to put the whole function on a MouseButton1Click event
After that, you’d want to call up the function PromptPurchase(). Now, if you want a button so that if you press it, it pops up with the prompt. To do that, you’d want to put the whole function on a MouseButton1Click event. The first parameter is what player you want to display the purchase prompt to, and that’s why I said to make a LocalScript instead of a regular script, since you can just put

players.LocalPlayer

in the player parameter.
The second parameter is just to get the model ID, so just copy and paste it.

local market = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local button = -- put the place of the button here
button.MouseButton1Click:Connect(function()
market:PromptPurchase(players.LocalPlayer, id)
end)

(replace “id” with the id of the free model you wanna put)
Now, you’d probably wanna make this more secure, maybe making smth that adds the script everytime someone removes it, but since i’m writing this at 11pm, i’m waaaaaaaaay to lazy to do that.

Sometimes you have imsomnia so you coded this at 11 pm ,well i play Roblox at 11 pm

1 Like

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