You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Fix the script
What is the issue? Include screenshots / videos if possible!
Game Pass script not working
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I asked the studio assistant and other developers.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local MarketplaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
local GamepassID = 134311828
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
that is incorrect, you can call promptgamepasspurchase from a localscript. im assuming either
1 - the id is incorrect
2 - the parent of this script isnt in screengui
By the looks of it, the script is directly parented under a GuiObject, specifically one with button functionalities.
Does the script work if I alter it like this?
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local GamepassID = 134311828
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
end)
Additionally, can you check that the script’s context is actually in client and not server? You can see it through Properties window.
if its in a surfacegui, then you need to set the parent of the surfacegui in startergui. then set the adornee (SurfaceGUI.Adornee) to the part its under
Someone correct me if I’m wrong, but I’m 90% sure a LocalScript won’t run if it is a descendant of the workspace (excluding the player’s character).
Change it to a server script and prompt with that, or use a RemoteEvent to communicate to the client to prompt it, or just get the button in a LocalScript under StarterPlayerScripts and prompt it there.