Advertisement
Sungmingamerpro13

VIPTools

May 18th, 2025
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.59 KB | None | 0 0
  1. --------------------
  2. --| WaitForChild |--
  3. --------------------
  4.  
  5. -- Waits for parent.child to exist, then returns it
  6. local function WaitForChild(parent, childName)
  7.     assert(parent, "ERROR: WaitForChild: parent is nil")
  8.     while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  9.     return parent[childName]
  10. end
  11.  
  12. -----------------
  13. --| Variables |--
  14. -----------------
  15.  
  16. local GamePassService = game:GetService('GamePassService')
  17. local PlayersService = game:GetService('Players')
  18. local LightingService = game:GetService('Lighting') --TODO: Use new data store service once that exists
  19.  
  20. local GamePassIdObject = WaitForChild(script, 'GamePassId')
  21. local AdminTools = WaitForChild(LightingService, 'VIPTools')
  22.  
  23. -----------------
  24. --| Functions |--
  25. -----------------
  26.  
  27. -- Makes copies of all the admin tools and puts them in target
  28. local function CloneAdminTools(target)
  29.     for _, tool in pairs(AdminTools:GetChildren()) do
  30.         local toolClone = tool:Clone()
  31.         toolClone.Parent = target
  32.     end
  33. end
  34.  
  35. -- When a player with the game pass joins, give them the admin tools
  36. local function OnPlayerAdded(player)
  37.     if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
  38.         local starterGear = WaitForChild(player, 'StarterGear')
  39.         CloneAdminTools(starterGear)
  40.         if player.Character then -- They've already loaded and won't get their StarterGear until next spawn
  41.             local backpack = WaitForChild(player, 'Backpack')
  42.             CloneAdminTools(backpack)
  43.         end
  44.     end
  45. end
  46.  
  47. --------------------
  48. --| Script Logic |--
  49. --------------------
  50.  
  51. PlayersService.PlayerAdded:connect(OnPlayerAdded)
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement
OSZAR »