I would like to set up an in-game gamepass purchase that gives you the tool after buying the game pass in-game. This would be very convenient for players purchasing game passes, because implementing the current script I have right now would require them to wait for the server to restart.
Here is what I have
local Id = 626438744 --Change this number to your Game Pass ID. script.Parent.ClickDetector.MouseClick:connect(function(player) game:GetService("MarketplaceService"):PromptPurchase(player, Id) end)
Help would be much appreciated.
local Id = 626438744 local Gamepass = game:GetService("GamePassService") local game.Players.PlayerAdded:connect(function(plr) if Gamepass:PlayerHasPass(player, Id) then game.LOCATIONOFTOOL.Toolname:clone().Parent = plr.Backpack game.LOCATIONOFTOOL.Toolname:clone().Parent = plr.StarterGear end)
This code should work.
local Id = 626438744 local Gamepass = game:GetService("GamePassService") local tool = game.ServerStorage:WaitForChild("TOOLNAME") --change tool name and make sure its in serverstorage game.Players.PlayerAdded:connect(function(plr) if Gamepass:PlayerHasPass(player, Id) then tool:Clone().Parent = plr.Backpack tool:Clone().Parent = plr.StarterGear end)