--serverscriptservice
local gamepassID = your id here
local toolName = "Taser"
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local function hasGamePass(player)
local success, result = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassID)
end)
if success then
return result
else
warn("Couldn't find gamepass for player:", player.Name)
return false
end
end
local function giveTool(player)
if not player.Backpack:FindFirstChild(toolName) and ReplicatedStorage:FindFirstChild(toolName) then
local tool = ReplicatedStorage:FindFirstChild(toolName):Clone()
tool.Parent = player.Backpack
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if hasGamePass(player) then
giveTool(player)
end
end)
end)
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedGamepassID, purchaseSuccess)
if purchaseSuccess and purchasedGamepassID == gamepassID then
giveTool(player)
end
end)
--
--local script in textbutton
local gamePassID = 926767265
local function promptPurchase()
local player = game.Players.LocalPlayer
game:GetService("MarketplaceService"):PromptGamePassPurchase(player, gamePassID)
end
script.Parent.MouseButton1Click:Connect(promptPurchase)
Watch video How to Create Tool Gamepass on Click - Roblox Studio Tutorial online, duration hours minute second in high quality that is uploaded to the channel fil1pex 21 September 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 222 times and liked it 9 visitors.