Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I fix my gamepass script? It keeps going to an item instead of a gamepass.

Asked by 5 years ago

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

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Simple Fix


The simple fix for this would be to change the instance of PromptPurchase to PromptGamePassPurchase

For Example:

MarketplaceService:PromptGamePassPurchase(player, GamePassID)


# other tips

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!

Ad

Answer this question