Can somebody please help me transform the following script so that it only works for people that own a certain gamepass?
Also if possible if the user doesn’t own the gamepass a popup appears that asks them if they’d like to buy the gamepass
local debounce = false
function onClicked(Clicker)
if debounce == false then
debounce = true
game.ServerStorage.SouthWestBuses.SWBOptareSolo:Clone().Parent = game.Workspace.SWBStorage
wait(10)
debounce = false
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
The script above simply moves a model from ServerStorage to the Workspace
You can just use MarketplaceService’s UserOwnsGamePassAsync function, and the ClickDetector parameter references the Player object
local GamepassID = 00000000 --Use your Gamepass ID here
local MarketplaceService = game:GetService("MarketplaceService")
local debounce = false
function onClicked(Player)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) and debounce == false then
debounce = true
game.ServerStorage.SouthWestBuses.SWBOptareSolo:Clone().Parent = game.Workspace.SWBStorage
wait(10)
debounce = false
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)