Gear Gamepass Issues (Speed and Gravity coils)

No, because all of those functions are firing, again, before the character is added. Here’s what you should be doing:

local marketPlaceService = game:GetService('MarketPlaceService')
local serverStorage = game:GetService('ServerStorage')
local players = game:GetService('Players')

local gamepassId = 19711172

players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
    local success, hasPass = pcall(function()
        return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)
    end)

    if success then
        if hasPass then
            serverStorage.Gravitycoil:Clone().Parent = player:WaitForChild('Backpack')
            serverStorage.Gravitycoil:Clone().Parent = player:WaitForChild('StarterGear')
        end
    else
        warn(hasPass)
    end
    end)
end)

I’ll test this now and report back

The same issues before, no tool is being given to the player

local marketPlaceService = game:GetService('MarketPlaceService')
local serverStorage = game:GetService('ServerStorage')
local players = game:GetService('Players')

local gamepassId = 19711172

players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
    local success, hasPass = pcall(function()
        return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)
    end)

    if success then
        if hasPass then
print("has pass")
print(hasPass)
            serverStorage.Gravitycoil:Clone().Parent = player:WaitForChild('Backpack')
            serverStorage.Gravitycoil:Clone().Parent = player:WaitForChild('StarterGear')
        end
    else
        warn(hasPass)
    end
    end)
end)

Could you tell me what this prints out?

local marketPlaceService = game:GetService('MarketPlaceService')
local serverStorage = game:GetService('ServerStorage')
local players = game:GetService('Players')

local gamepassId = 19711172

players.PlayerAdded:Connect(function(player)
    local success, hasPass = pcall(function()
        return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)
    end)

    if success then
        if hasPass then
            player.CharacterAdded:Connect(function()
                serverStorage.Gravitycoil:Clone().Parent = player:WaitForChild('Backpack')
            end)
        end
    else
        warn(hasPass)
    end
end)

Try disabling this script and use the code I gave you earlier and see if that works.

Does it work if you remove WaitForChild() ?

I also noticed that you forgot to add game:GetService(“MarketplaceService”) in the if statement

local GamePassId = 19711172

game.Players.PlayerAdded:Connect(function(player)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamePassId) then
		game.ServerStorage.Gravitycoil:Clone().Parent = player.Backpack
		game.ServerStorage.Gravitycoil:Clone().Parent = player.StarterGear
	end
end)

same problem as others, tool is not given to me after buying the gamepass in a Studio test.

still does not give the coil as intended

Are you sure the coil can be given to you? (is ‘RequiresHandle’ on but the tool has no handle)

Can I see the location of everything necessary? All the trees of every instance location? Like screenshots of where the coil is located, and the scripts?

The code you’re running is not part of the event, put it inside the PlayerAdded function.

 local GamePassId = 19711172

 	game.Players.PlayerAdded:Connect(function(player)

		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId) then

 			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("Backpack")
 			game.ServerStorage.Gravitycoil:Clone().Parent = player:WaitForChild("StarterGear")
 		end
 end)

‘RequiresHandle’ is on, and Gravity Coil has a handle.

Yeah one second, need to swap computers for ease of screenshotting.

Here are the screenshots and where they are located:

Screen Shot 2021-07-10 at 20.44.08 Screen Shot 2021-07-10 at 20.44.20 Screen Shot 2021-07-10 at 20.44.30

Game Pass buying button (Starter Gui, ‘Gravity’, Local Script.

Tools located in server storage (titled GravityCoil now, at the start of this thread was a lower c on Coil)

Game Pass Giver Script called ‘Script’ in ServerScriptService

I has to be

game:GetService(“ServerStorage”).GravityCoil:Clone().Parent = player:WaitForChild(“Backpack”)

Try changing the sections like that. Your code has Gravitycoil, but the actual name of it is GravityCoil

DID NOT READ YOUR POST CORRECTLY, Ignore this then lol

Try using this code. You place the tool you want to give inside the script, replace ‘gamepassid’ with your passid and replace script.tool with the tool name.

local MarketPlaceService = game:GetService("MarketplaceService")
 
local GamepassId = 1234567 -- REPLACE 1234567 WITH YOUR GAMEPASS ID
local Tool = script.GravityCoil -- REPLACE GravityCoil WITH THE NAME OF YOUR TOOL
 
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)
1 Like

Dukzae is right over here, the tool should be cloned into the backpack each time the player spawns.

Do not place your tools in ReplicatedStorage. The clients have access to this, and can clone it on their own to use.

I looked over your code, and noticed some spelling problems, case sensitivity problems, and efficiency problems that I can help with. One thing to note is “UserOwnsGamePassAsync” is an expensive function, and you really don’t want to be calling it each time the character spawns. That’s why you should only call it once when the player joins, and depending on whether they own it or not, clone the tool when they spawn.

-- Services and Variables
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ServerStorage = game:GetService("ServerStorage")
local GAMEPASS_ID = 19711172

-- A cache to index if a player owns the gamepass when they join
local cache = {}

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		-- Repeats until ownership is detected
		if cache[player] == nil then
			repeat 
				wait()
			until
			cache[player] ~= nil
		end
		
		-- If the player owns the gamepass, clone the gravity coil into their backpack
		local ownsGamepasses = cache[player]
		if ownsGamepasses then
			ServerStorage.GravityCoil:Clone().Parent = player:WaitForChild("Backpack")
		end
	end)
	
	-- This runs ONLY ONCE because UserOwnsGamePassAsync is an expensive function
	-- IT shouldn't be called every time the player spawns, so ownership will be indexed in the cache
	local success, hasPass = pcall(function()
		return MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAMEPASS_ID)
	end)
	if success then
		cache[player] = hasPass
	else
		warn("Failed to retrieve ownership data: " .. player.Name) 
		cache[player] = false
	end
end)

I said this in the explanation below…thats not the problem Coil vs coil anymore.

No errors, yet tool is still not given after purchasing