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

Gamepass script help GUI filtering enabled?

Asked by 6 years ago

I tried the Roblox thing and that didn't help at all I tried youtube (Not preferably the best thing to do) but nothing. I tried myself nope. Anyways how would I make a gamepass script, within' a gui I know how to make a gui i just don't know what to put in the button to make it where if you click it and you own the game pass you'll get the tool.

The problem I don't know how to do this on filtering enabled. So any help would be amazing (In fe)

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

You can use MarketplaceService:PlayerOwnsAsset(). Note that you are going to need to turn the gamepass id to its asset id. You can do that by using this api.

Server script:

local gamePassAssetId = 0 --replace with your gamepass's asset id

local tool = game:GetService("ServerStorage").SomeTool --replace

local toolRemote = Instance.new("RemoteEvent", game:GetService"ReplicatedStorage")
toolRemote.Name = "toolRemote"
toolRemote.OnServerEvent:Connect(function(plr)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, gamePassAssetId) then
        tool:Clone().Parent = plr.Backpack
    end
end)

Local script:

local toolRemote = game:GetService"ReplicatedStorage":WaitForChild"toolRemote"
local button = script.Parent
button.MouseButton1Click:Connect(function()
    toolRemote:FireServer()
end)
Ad

Answer this question