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

Member of "Players" that represents all of the players in the server?

Asked by 5 years ago
    plr = game.Players. -- Missing

local button = script.Parent

local marketplaceService = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()

MarketplaceService:PromptGamePassPurchase(plr, 6255391)

end)

So this is the script I used to create a ScreenGui TextButton that offers a gamepass, but I'm a noob, so I need the member of "Players" that represents all of the players in the server. If someone could please tell me what that would be, I would greatly appreciate it, thanks!

1 answer

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago

What you did wrong is that Players is a service, and so it doesn't do anything. Since you're prompting the service a gamepass purchase it won't work since it has to be a player. What I'm assuming here is that this is a LocalScript located inside of a TextButton/ImageButton. So we're going to modify it to fit our needs.

local Player = game:GetService("Players").LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")
local Button = script.Parent

local function onClicked()
    MarketplaceService:PromptGamePassPurchase(Player,6255391)
end

Button.MouseButton1Click:Connect(onClicked)

In the code what we're doing is that we get the Player, MarketPlaceService, and the Button. Every time the button is clicked it prompts the player the gamepass.

Ad

Answer this question