Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tableOfGamepassesAndTheirEffects = {}
- tableOfGamepassesAndTheirEffects[543274611]=(function(Player, loadedGamepassesForPlayer, Id)
- if loadedGamepassesForPlayer[Id]~= nil then print(Id, "Already loaded") return end --if you already successfully checked this gamepass id, dont check again
- if thisIsALobbyServer == false and marketplaceService:PlayerOwnsAsset(Player, Id) then --if the server is a game server(to avoid a worthless call) and the player also owns the gamepass,
- Instance.new("BoolValue", Player.GamepassesOwned).Name=Id --create the boolvalue so the client knows,
- playersTab[Player.Name].skinsOwned[tostring(Id)]=true --remember it in the table for future things
- end
- loadedGamepassesForPlayer[Id]=true --if no errors happened, the check was successful
- return loadedGamepassesForPlayer
- end)
- --lot more gamepasses, but they all look the same
- function loadGamepassesForPlayer(Player, loadedGamepassesForPlayer)
- loadedGamepassesForPlayer = loadedGamepassesForPlayer or {} --if there's no table passed in, create an empty one
- local successfullyLoadedAllGamepasses = true
- for Id, v in pairs(tableOfGamepassesAndTheirEffects) do --scan through all the gamepass IDs and their functions
- local Success, errorMessage = pcall(function()
- loadedGamepassesForPlayer = tableOfGamepassesAndTheirEffects[Id](Player, loadedGamepassesForPlayer, Id) or loadedGamepassesForPlayer -- run the function for that gamepass id and send the table of gamepasses that have been successfully checked
- end)
- if Success ~= true then --if the function above failed for some reason, then not all gamepasses were successfully checked
- warn("Fail here", errorMessage)
- successfullyLoadedAllGamepasses = false -- loop through the table again
- end
- end
- if successfullyLoadedAllGamepasses == false and Player~= nil and Player.Parent == Players then --if there were any errors last loop, and the player is still again, run through the list of gamepasses again
- wait(1)
- warn("Running load gamepasses func again")
- loadGamepassesForPlayer(Player, loadedGamepassesForPlayer)
- end
- print("Finished checking for gamepasses")
- return true
- end
- loadGamepassesForPlayer(Player)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement