I have looked but couldn’t find a solution. I have a gamepass that gives the player a tool. It works but you have to rejoin for the gamepass to give you the tool. I want to code a script that gives the player the tool instantly instead of having to rejoin. This is my code:
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 0
function Spawned(player)
local HasGamepass = false
local success, message = pcall(function()
HasGamepass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
end)
if not success then
return
end
if HasGamepass == true then
game.ServerStorage.ClassicSword:Clone().Parent = player.Backpack
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
Spawned(player)
end)
end)
Players.PlayerSpawned:Connect(Spawned)