not sure if this counts as scripting but I just made a gamepass, it gives you the gamepass when you make it. But in my game when I check with the ID of the gamepass (i copy and pasted from the roblox link), it prints I do not have the gamepass. how come?
local players = game:GetService("Players")
local gamePassID = 940424664
local function playerHasGamePass(player)
local success, hasGamePass = pcall(function()
return player:HasPass(gamePassID)
end)
return success and hasGamePass
end
local function onPlayerChatted(player, message)
local command, numberStr = message:match("^(%S+)%s*(%S*)$")
if command == "!clone" then
if not playerHasGamePass(player) then
print(playerHasGamePass(player)) -- prints false (but i used the ID)
return
end
--i put the rest of the script here
end
end
players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
onPlayerChatted(player, message)
end)
end)
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local gamePassID = 940424664
local function playerHasGamePass(player)
local success, hasPass = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
return success and hasPass
end
local function onPlayerChatted(player, message)
local command, numberStr = message:match("^(%S+)%s*(%S*)$")
if command == "!clone" then
local hasPass = playerHasGamePass(player)
print("Player has game pass:", hasPass)
if not hasPass then
warn("Player " .. player.Name .. " doesn't have the required game pass!")
return
end
-- Rest of your clone logic here
end
end
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
onPlayerChatted(player, message)
end)
end)