I made a gamepass tool script but it does not work. It does not even print anything but it’s supposed to if i have the gamepasses, serverside script
(also i have the passes by default)
Script:
wait(1)
game.Players.PlayerAdded:connect(function(Player)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 174984875) then
print("HasGP")
local cln = game.ServerStorage:FindFirstChild("Trap Money Bag"):Clone()
cln.Parent = Player.Backpack
end
end)
game.Players.PlayerAdded:connect(function(Player)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 174985701) then
print("HasGP")
game.ServerStorage.ChildAdded:Connect(function(hit)
if hit:IsA("Folder") and hit.Name == "Pistols" then
local descendants = game.ServerStorage:FindFirstChild("Pistols"):GetDescendants()
for _, descendant in pairs(descendants) do
if descendant:IsA("Tool") then
local cln = descendant:Clone()
cln.Parent = Player.Backpack
print("Added")
end
end
end
end)
end
end)
The problem could also be the wait(1) on the top of the script. Events like the ones written in the script should be connected immediately when a game starts to ensure proper working of it, or else, if a player joins the game at the time the event is not connected, the connected function of the event will not even fire.
game.Players.PlayerAdded:connect(function(Player)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 174984875) then
print("HasGP")
local cln = game.ServerStorage:WaitForChild("Trap Money Bag"):Clone()
cln.Parent = Player.Backpack
else
print("NoGP")
end
end)
game.Players.PlayerAdded:connect(function(Player)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 174985701) then
print("HasGP")
local descendants = game.ServerStorage:WaitForChild("Pistols"):GetDescendants()
for _, descendant in pairs(descendants) do
if descendant:IsA("Tool") then
local cln = descendant:Clone()
cln.Parent = Player.Backpack
print("Added")
end
end
else
print("NoGP")
end
end)