Hey there! I want to make a “Buy” button where you’re at proximity to something. I think you need to use the thing called “Proximity Prompt” but as a noob developer I’m not sure.
Hope you can help me! Thanks!
If I do some grammaticals faults, sorry, I’m french and I’m not amazingly good at English
When you’re near to the thing it print a “Buy” button and when you click “E” it print the buy panel (where, if you click Buy it use your Robux for buying it).
You can put proximity prompt in a part and put a local script in it with this code then i think it’ll work.
And also don’t forget to make RequiresLineOfSight option on proximityprompt “false” because you may not see the proximity prompt when ur near the part if its true.
If you want to edit the strings on the proximity prompt then you can change the ObjectText to the name of the thing like “2x Speed” or something and ActionText to “Buy”
local id = --gamepass id
script.Parent.Triggered:Connect(function()
game.MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, id)
end)
This is my first reply on this forum either sorry if anything is wrong.
I tried the script but it seems like its not working on local script so you can just change the script to normal script and put this code in it.
local id = --gamepass id
local MarketPlace = game:GetService("MarketplaceService")
script.Parent.Triggered:Connect(function(player)
MarketPlace:PromptGamePassPurchase(player, id)
end)
Just create a part and put a ProximityPrompt object in it, then put a Script in ProximityPrompt and paste the second code i’ve sent into that. Then You can edit the properties of ProximityPrompt to make it better. Like changing its ObjectText, ActionText, Hold Duration etc. And like i said ProximityPrompts also has an option which is named RequiresLineOfSight, making it false fixes the problem when you are not able to see the ProximityPrompt because its stuck in the part.
Yeah sorry firstly i thought localscript would work because i used one in an UI but seems like it does not work in proximityprompt so i said to change the type of the script.
I’ll try your script. I’ll tell you if it work! Also just one think, is this also working if I want to make a button for an UGC item instead of a gamepass?
I don’t exactly know anything about UGC, so i can’t say anything useful. Also i don’t think it would work by changing the gamepass ID to UGC ID because it does not count as a gamepass so yeah, thats all from me lol.