You can write your topic however you want, but you need to answer these questions:
-
Hello! I am trying to make a button that only activates if a player owns a gamepass, it activates from a click detector.
-
I want to make it so that if the player clicks it but doesn’t own the gamepass that it prompts the player the gamepass and kills the player but I don’t know how to yet,
-
I have looked through the DevForum beforehand and found gamepass buttons but none kill the player if they don’t own the gamepass.
The button if the gamepass is owned will activate a self-destruct mode inside my game which I have already accomplished.
SCRIPT
local MPS = game:GetService("MarketplaceService")
local gamepassId = 45131258
local function promptPurchase(Player)
local hasPass = false
local success, message = pcall(function()
hasPass = MPS:UserOwnsGamePassAsync(Player.UserId, gamepassId)
end)
if hasPass == true then
workspace.SelfDestruct.Disabled = false
script.Disabled = true
else
-- stuck here with killing player
MPS:PromptGamePassPurchase(Player, gamepassId)
end
end
script.Parent.ClickDetector.MouseClick:Connect(promptPurchase)
Please let me know if you can help!