I've been having a problem with putting gamepasses in my game for some reason. here's the code and please tell me if you find something wrong about it. some of the script works (like the color changing admin button) but what isn't working is the id part most likely, it sends it to an item instead of a gamepass. -- params : ...
local ID = 61844722
local player = game.Players.LocalPlayer
onClick = function()
game:GetService("MarketplaceService"):PromptPurchase(player, ID)
end
script.Parent.MouseButton1Click:connect(onClick)
while wait(1) do
script.Parent.Text = "Purchase Admin Commands"
script.Parent.TextLabel.Text = "Purchase Admin Commands"
script.Parent.TextColor3 = Color3.new(math.random(1, 255) / 255, math.random(1, 255) / 255, math.random(1, 255) / 255)
wait(1)
script.Parent.Text = "Click For Admin Commands!"
script.Parent.TextLabel.Text = "Click For Admin Commands!"
script.Parent.TextColor3 = Color3.new(math.random(1, 255) / 255, math.random(1, 255) / 255, math.random(1, 255) / 255)
end
The simple fix for this would be to change the instance of PromptPurchase
to PromptGamePassPurchase
For Example:
MarketplaceService:PromptGamePassPurchase(player, GamePassID)
It is also encouraged not make use of wait()
as a condition for while loops, and instead use a boolean, as that will increase the readability of your script.
Be sure to accept if it helped!