Hey guys. So, I'm not at all new to gamepasses, but for whatever reason it may be, the game claims I do not own the gamepass I created myself (and the page says I own it aswell!)
I made a print to show me if I have it or not, and when playing the game, it prints the "doesnt own", even though, very clearly, I do own it.
Is this a scripting error?
id = mypassidwenthere game.Players.PlayerAdded:connect(function(plr) repeat wait() until plr.Character if game:GetService("GamePassService"):PlayerHasPass(plr, id) then local tool = script:FindFirstChild("Spear") tool:Clone().Parent = plr.Backpack tool:Clone().Parent = plr.StarterGear print("Given") else print("doesnt own") end end)
PlayerHasPass
is deprecated; use UserOwnsGamepassAsync
instead. My buddy vissequ made a script for this purpose and he's welcome to share it with anyone.
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local gamePassID = --YourGamePassIdHere function onPlayerSpawned(player) local hasPass = false -- Check if the player already owns the game pass local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) print("Has Game Pass") end) -- If there's an error, issue a warning and exit the function if not success then warn("Error while checking if player has pass: " .. tostring(message)) return end if hasPass == true then -- Your Code Here end end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function() onPlayerSpawned(player) end) end) -- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function Players.PlayerAdded:Connect(onPlayerSpawned) --Script Created by Vissequ
(This Script is confirmed working, so If it still doesn't work, it's on you.) P.S. I highly recommend you don't put your tools inside your script, because that's what you're refrencing in your script, and you put them in ReplicatedStorage. Also, This script won't run if it isn't in Workspace or ServerScriptService, as a Server Script.