Hi, i made something like a part and inside of it, a surface GUI and inside a Image button and then inside of it a local script.
local player = game.Players.LocalPlayer
local marketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 22612992
script.Parent.MouseClick:Connect(function()
marketPlaceService:PromptGamePassPurchase(player,gamePassId)
end)
tbh im not sure but the first parameter for PromptGamePassPurchase would be the player id not the player instance and the ui buttons use MouseButton1Click as their event not MouseClick
local players = game:GetService("Players")
local player = game.Players.LocalPlayer
local marketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 22612992
script.Parent.MouseButton1Click:Connect(function()
marketPlaceService:PromptGamePassPurchase(player.UserId, gamePassId)
end)
local players = game:GetService("Players")
local player = players.LocalPlayer
local marketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 22612992
workspace.Part.SurfaceGui.ImageButton.MouseButton1Click:Connect(function()
marketPlaceService:PromptGamePassPurchase(player.UserId,gamePassId)
end)
try this,i just realised that youre putting it in a part which is in the workspace and local scripts dont work on workspace,instead you have to put the script in the PlayerGui and reference the ui from the PlayerGui
local players = game:GetService("Players")
local player = players.LocalPlayer
local marketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 22612992
game.Workspace.GamePassPart.SurfaceGui.ImageButton.MouseButton1Click:Connect(function()
marketPlaceService:PromptGamePassPurchase(player.UserId, gamePassId)
end)
Put the script into the StarterPlayerScripts folder, rename the part to “GamePassPart” make sure it is parented to the workspace.