If Player has game Pass, When Joins Server To Have A Specific Tool, I Tried but it doesn't work!
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 440994981 -- Change this to your game pass ID
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 for Gun")
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
game.ServerStorage.GravityCoil:clone().Parent = player.Backpack
end
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function()
onPlayerSpawned(player)
end)
end)
-- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function
Players.PlayerSpawned:Connect(onPlayerSpawned)
