Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why don't my gamepasses show up in game sometimes?

Asked by
cfojo -5
5 years ago

I made a game, the gamepasses show up when the server is relatively empty, but after that they do not. I have it set up so it checks to see if the player owns the gamepass, and then copies the model from Lighting to put it in the player's inventory.

Script:

game.Players.PlayerAdded:connect(function(player) while true do if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 4988705) then if player.Backpack:FindFirstChild("Broomstick") == nil and player.Character:FindFirstChild("Broomstick") == nil then print(player.Name .. " got an item!") local b = game.Lighting:FindFirstChild("Broomstick"):Clone() b.Parent = player.Backpack end end wait(1)
end end)

Broomstick is the name of the tool in Lighting that is being cloned. Why is this unreliable?

0
Please use serverstorage MaxDev_BE 55 — 5y
0
Use serverstorage for what? The tools? cfojo -5 — 5y
0
Can you put your code in a code block MythicalShade 420 — 5y
0
Don't use lighting as a storage, use ServerStorage for the tools, or anything honestly. Pojoto 329 — 5y
View all comments (4 more)
0
Seems kinda excessive that you have an endless loop running for each player that joins constantly checking if they own the pass and all, I would change it to CharacterAdded or a button Vulkarin 581 — 5y
0
Try this: game:GetService("MarketplaceService"):PlayerOwnsAsset(player.userId, 4988705) hellmatic 1523 — 5y
0
@ above I believe UserOwnsGamepassAsync is a better way of doing it green271 635 — 5y
0
yes and userId is deprecated User#19524 175 — 5y

Answer this question