Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Gamepass script help GUI filtering enabled?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.