The gamepass tool is only available in the studio, not in the game

I only get the gamepass tool in studio, but not in game.

Studio:

Roblox:

Script:

local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local ServerStorage = game:GetService("ServerStorage")

local Tools = ServerStorage.Tools

Players.PlayerAdded:Connect(function(Player)
	print(Player.Name)
	if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 54156299) then
		Tools.HealingPotion:Clone().Parent = Player.Backpack
	end

	if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 54155868) then
		Tools.SpeedCoil:Clone().Parent = Player.Backpack
	end

	if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 54155692) then
		Tools.Flashlight:Clone().Parent = Player.Backpack
	end
	print(MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 54156299))
end)

Perhaps seperate the 3 if then end functions into different PlayerAdded threads? Or file this in engine bugs…

1 Like

Okay I will post this on engine bugs maybe its a bug.

Nvm, I can’t post on engine bugs category.

Have you tried publishing the game? Perhaps the server hasn’t updated yet.

2 Likes

I already publish the game many times. It does print the player name and print true or false if the player owns the gamepass or not.

Do you own the gamepass??? Roblox studio works locaclly. Probably a bug though.

1 Like

yeah I do own the gamepass in the game.

Then there’s nothing we can do. The script should work perfectly fine. Therefore, the best conclusion I can tell you is that the problem is a bug like @CremaCoffeeOverseer said.

1 Like

Sadly I can’t post on engine bugs category.

Now I’m just having random guesses, but usually you put player instead of Player inside the function. For example, Hit and hit are very different. Try using the lower-case letter “player.”

1 Like

I always use Player and I have no issue but I will try what you said.

It’s just random guesses at this point.

1 Like

didn’t work but thanks for helping me.

1 Like

Have you checked if there are any errors in the output in-game? Does the print messages show up in the output when in game?

No errors and it print messages in the output when in game same with studio

I see. Maybe add a task.wait() in the PlayerAdded event before running the rest of the code in the block. Maybe even add a WaitForChild when parenting the tools to the backpack.

1 Like

I already tried that but it still didn’t work as intended.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GamepassId = 22429147 

function PlayerSpawn(Plr) 

	local PlrHasGamepass = false

	local Sucess, FailedTry = pcall(function()
		PlrHasGamepass = MarketplaceService:UserOwnsGamePassAsync(Plr.userId, GamepassId)
	end)

	if not Sucess then
		warn("Error while checking if player has gamepass: " .. tostring(FailedTry))
		return
	end

	if PlrHasGamepass == true then
		script.Flashlight:Clone().Parent = Plr.Backpack
		script.HealingPotion:Clone().Parent = Plr.Backpack
		script.SpeedCoil:Clone().Parent = Plr.Backpack
	end
end 

game.Players.PlayerAdded:connect(function(Player)
	Player.CharacterAdded:connect(function()
		PlayerSpawn(Player)
	end)
end)

Players.PlayerSpawned:Connect(PlayerSpawn)

Insert the tools in the script

1 Like

this is so weird, it happened to me to, then, all of a sudden the game fixed itself?? I have no idea what happened.