GamePasses only work in studio

  1. What do you want to achieve?
    I want to check if the player has my gamepass and if he does then I will give him a tool, like every gamePass that exists.

  2. What is the issue?
    The player only gets the tool in Studio but not inside the actual Roblox game.

  3. What solutions have you tried so far?
    I’ve tried looking for similar problems but couldn’t find any results.

image

Detecting script (Inside SSS)

local passIDs = {
	gravity = "78825491",
	speed = "78826675"
}
local mod = require(game:GetService("ServerStorage"):WaitForChild("Mod").XFunctions)
local tools = game:GetService("ServerStorage"):WaitForChild("Tools").gamePassTools

local gamePassUsers = {273486324, 3614108279}

game.Players.PlayerAdded:Connect(function(plr)
	
	local hasPassGravity = mod.checkPass(plr, passIDs.gravity)
	local hasPassSpeed = mod.checkPass(plr, passIDs.speed)
	
	if hasPassGravity then
		mod.giveTool(plr, tools.GravityCoil, false)
	end
	
	if hasPassSpeed then
		mod.giveTool(plr, tools.SpeedCoil, false)
	end
	
	for i, id in ipairs(gamePassUsers) do
		if id == plr.UserId then
			for i, tool in ipairs(tools:GetChildren()) do
				mod.giveTool(plr, tool, false)
			end
			break
		end
	end
end)

ToolGiver (Inside serverStorage)
I know that the function works bc I can give players tools with it in other scripts

local BService = game:GetService("BadgeService")
local MPS = game:GetService("MarketplaceService")

local module = {

checkPass = function(plr, id)
		local has = false
		local success, errorMsg = pcall(function()
			has = MPS:UserOwnsGamePassAsync(plr.UserId, id)
		end)
		if success then return has end
		if errorMsg then
			warn("Failed UserOwnGamePassAsync, set value to false")
			return has
		end
	end,

	giveTool = function(plr, tool, equip)
		local toolClone = tool:Clone()		
		if equip then toolClone.Parent = plr.Character else toolClone.Parent = plr.Backpack end
	end,
}

return module

image

game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id)
1 Like

I’ve already checked if the player has the gamePass.

I think I know why, I’ll reply the results.

I had to wait for the character to load in, mb.