Gamepass script not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want my Medkit to be in the inventory of the people who bought it and for it to work.

  1. What is the issue? Include screenshots / videos if possible!

Somehow my screengui is blocking it from working because everytime I get rid of it, it works. I have no idea how it is because it is a ScreenGui for a leave button. Yet, it works everytime in studio when I Gui is there.

(Code will be at the end).

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I looked around but could not find anything, and I tried random stuff but nothing worked.

Code for getting the Medkit

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)

Players.PlayerAdded:Connect(function(player)
wait()
local ownsGamepass = MarketplaceService:UserOwnsGamePassAsync(player.UserId,20791449)
if ownsGamepass then
local Medkit = ReplicatedStorage:WaitForChild(“Medkit”):Clone()
Medkit.Parent = player.Backpack
end
end)

Pictures of the screen GUI

4 Likes

Use this script.

-- greenalien268 :)

– I suggest storing this script inside ServerScriptService or Workspace
– Sorry about it not working earlier, V2

local Id = 20381983 – Put the gamepass id here, it is found in the url and is the number part
local VipPlayers = {""} – Any person’s name put here will get the gamepass for free
local ToolName = {“Put your tool name here”} – Put the name of your tool here that MUST be stored in ServerStorage

local function FindPlayer(Plr)
for Num, Pler in pairs(VipPlayers) do
if Pler == Plr then
return true
end
end
end

game.Players.PlayerAdded:connect(function(Player)
if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(Player.UserId, Id) or FindPlayer(Player.Name) then
Player.CharacterAdded:Connect(function(character)
for Num, Tool in pairs(ToolName) do
if game:GetService(“ServerStorage”):FindFirstChild(Tool) then
game:GetService(“ServerStorage”)[Tool]:Clone().Parent = Player.Backpack
end
end
end)

	for Num, Tool in pairs(ToolName) do
		if Player.Backpack:FindFirstChild(Tool) == nil then
			if game:GetService("ServerStorage"):FindFirstChild(Tool) then
				game:GetService("ServerStorage")[Tool]:Clone().Parent = Player.Backpack
			end
		end
	end
end

end)

Howdy! I am here to help you with this problem. Go to ServerScriptService, make a script, add the medkit to the script, and paste the following code in:

local MarketPlaceService = game:GetService("MarketplaceService")
 
local GamepassId = --YOUR ID
local Tool = script.ToolName
 
game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
            local ToolClone = Tool:Clone()
            ToolClone.Parent = Player.Backpack
        end
    end)
end)

Hope this works!

Did not seem to work out right.

I just have no idea what to do with the second part of that script.

  1. Did you “buy” or actually buy the gamepass?
  2. Did you try resetting and seeing if it then was in your inventory?
  3. Did you check the spelling of your toolname and / or did you enter the correct gamepass ID?

I looked up some videos and found a solution. So I am good, but yes I did buy the game pass.

1 Like