Advertisement
Someone55555

Untitled

May 4th, 2025
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2.  
  3. local AssetService = game:GetService("AssetService")
  4.  
  5. local TeleportService = game:GetService("TeleportService")
  6.  
  7. local player = Players.LocalPlayer
  8.  
  9. local playerGui = player:WaitForChild("PlayerGui")
  10.  
  11. -- Create ScreenGui
  12.  
  13. local screenGui = Instance.new("ScreenGui")
  14.  
  15. screenGui.Name = "SubPlacesGui"
  16.  
  17. screenGui.Parent = playerGui
  18.  
  19. -- Create main frame
  20.  
  21. local mainFrame = Instance.new("Frame")
  22.  
  23. mainFrame.Size = UDim2.new(0, 400, 0, 300)
  24.  
  25. mainFrame.Position = UDim2.new(0.5, -200, 0.5, -150)
  26.  
  27. mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  28.  
  29. mainFrame.BorderSizePixel = 0
  30.  
  31. mainFrame.Parent = screenGui
  32.  
  33. -- Title label
  34.  
  35. local titleLabel = Instance.new("TextLabel")
  36.  
  37. titleLabel.Size = UDim2.new(1, 0, 0, 30)
  38.  
  39. titleLabel.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
  40.  
  41. titleLabel.TextColor3 = Color3.new(1, 1, 1)
  42.  
  43. titleLabel.Font = Enum.Font.SourceSansBold
  44.  
  45. titleLabel.TextSize = 20
  46.  
  47. titleLabel.Text = "Sub-Places"
  48.  
  49. titleLabel.Parent = mainFrame
  50.  
  51. -- Show Sub-Places Button
  52.  
  53. local showButton = Instance.new("TextButton")
  54.  
  55. showButton.Size = UDim2.new(0, 150, 0, 40)
  56.  
  57. showButton.Position = UDim2.new(0.5, -75, 0, 40)
  58.  
  59. showButton.BackgroundColor3 = Color3.fromRGB(70, 130, 180)
  60.  
  61. showButton.TextColor3 = Color3.new(1, 1, 1)
  62.  
  63. showButton.Font = Enum.Font.SourceSansBold
  64.  
  65. showButton.TextSize = 18
  66.  
  67. showButton.Text = "Show Sub-Places"
  68.  
  69. showButton.Parent = mainFrame
  70.  
  71. -- Scrolling frame to hold place buttons
  72.  
  73. local scrollingFrame = Instance.new("ScrollingFrame")
  74.  
  75. scrollingFrame.Size = UDim2.new(1, -20, 1, -100)
  76.  
  77. scrollingFrame.Position = UDim2.new(0, 10, 0, 90)
  78.  
  79. scrollingFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  80.  
  81. scrollingFrame.BorderSizePixel = 0
  82.  
  83. scrollingFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
  84.  
  85. scrollingFrame.ScrollBarThickness = 8
  86.  
  87. scrollingFrame.Parent = mainFrame
  88.  
  89. -- UIListLayout for scrolling frame
  90.  
  91. local listLayout = Instance.new("UIListLayout")
  92.  
  93. listLayout.Padding = UDim.new(0, 5)
  94.  
  95. listLayout.SortOrder = Enum.SortOrder.LayoutOrder
  96.  
  97. listLayout.Parent = scrollingFrame
  98.  
  99. -- Function to clear previous entries
  100.  
  101. local function clearSubPlaceEntries()
  102.  
  103. for _, child in pairs(scrollingFrame:GetChildren()) do
  104.  
  105. if child:IsA("Frame") then
  106.  
  107. child:Destroy()
  108.  
  109. end
  110.  
  111. end
  112.  
  113. end
  114.  
  115. -- Function to create a sub-place entry with place name and place ID
  116.  
  117. local function createSubPlaceEntry(place)
  118.  
  119. local entryFrame = Instance.new("Frame")
  120.  
  121. entryFrame.Size = UDim2.new(1, 0, 0, 50) -- Increased height to fit two labels
  122.  
  123. entryFrame.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
  124.  
  125. entryFrame.Parent = scrollingFrame
  126.  
  127.  
  128.  
  129. local placeNameLabel = Instance.new("TextLabel")
  130.  
  131. placeNameLabel.Size = UDim2.new(0.6, 0, 0.5, 0)
  132.  
  133. placeNameLabel.BackgroundTransparency = 1
  134.  
  135. placeNameLabel.TextColor3 = Color3.new(1, 1, 1)
  136.  
  137. placeNameLabel.Font = Enum.Font.SourceSansBold
  138.  
  139. placeNameLabel.TextSize = 18
  140.  
  141. placeNameLabel.Text = "Name: " .. tostring(place.Name or "Unknown")
  142.  
  143. placeNameLabel.TextXAlignment = Enum.TextXAlignment.Left
  144.  
  145. placeNameLabel.Parent = entryFrame
  146.  
  147.  
  148.  
  149. local placeIdLabel = Instance.new("TextLabel")
  150.  
  151. placeIdLabel.Size = UDim2.new(0.6, 0, 0.5, 0)
  152.  
  153. placeIdLabel.Position = UDim2.new(0, 0, 0.5, 0)
  154.  
  155. placeIdLabel.BackgroundTransparency = 1
  156.  
  157. placeIdLabel.TextColor3 = Color3.new(1, 1, 1)
  158.  
  159. placeIdLabel.Font = Enum.Font.SourceSans
  160.  
  161. placeIdLabel.TextSize = 16
  162.  
  163. placeIdLabel.Text = "PlaceId: " .. tostring(place.PlaceId)
  164.  
  165. placeIdLabel.TextXAlignment = Enum.TextXAlignment.Left
  166.  
  167. placeIdLabel.Parent = entryFrame
  168.  
  169.  
  170.  
  171. local joinButton = Instance.new("TextButton")
  172.  
  173. joinButton.Size = UDim2.new(0.35, 0, 0.8, 0)
  174.  
  175. joinButton.Position = UDim2.new(0.65, 0, 0.1, 0)
  176.  
  177. joinButton.BackgroundColor3 = Color3.fromRGB(100, 170, 100)
  178.  
  179. joinButton.TextColor3 = Color3.new(1, 1, 1)
  180.  
  181. joinButton.Font = Enum.Font.SourceSansBold
  182.  
  183. joinButton.TextSize = 18
  184.  
  185. joinButton.Text = "Join"
  186.  
  187. joinButton.Parent = entryFrame
  188.  
  189.  
  190.  
  191. joinButton.MouseButton1Click:Connect(function()
  192.  
  193. -- Teleport player to the selected place
  194.  
  195. TeleportService:Teleport(place.PlaceId, player)
  196.  
  197. end)
  198.  
  199. end
  200.  
  201. -- On clicking Show Sub-Places button
  202.  
  203. showButton.MouseButton1Click:Connect(function()
  204.  
  205. showButton.Text = "Loading..."
  206.  
  207. showButton.Active = false
  208.  
  209. showButton.AutoButtonColor = false
  210.  
  211.  
  212.  
  213. clearSubPlaceEntries()
  214.  
  215.  
  216.  
  217. local success, pagesOrError = pcall(function()
  218.  
  219. return AssetService:GetGamePlacesAsync()
  220.  
  221. end)
  222.  
  223.  
  224.  
  225. if success then
  226.  
  227. local pages = pagesOrError
  228.  
  229. local allPlaces = {}
  230.  
  231.  
  232.  
  233. -- Iterate through all pages to collect all places
  234.  
  235. repeat
  236.  
  237. for _, place in ipairs(pages:GetCurrentPage()) do
  238.  
  239. table.insert(allPlaces, place)
  240.  
  241. end
  242.  
  243. if not pages.IsFinished then
  244.  
  245. pages:AdvanceToNextPageAsync()
  246.  
  247. end
  248.  
  249. until pages.IsFinished
  250.  
  251.  
  252.  
  253. if #allPlaces == 0 then
  254.  
  255. local noPlacesLabel = Instance.new("TextLabel")
  256.  
  257. noPlacesLabel.Size = UDim2.new(1, 0, 0, 40)
  258.  
  259. noPlacesLabel.BackgroundTransparency = 1
  260.  
  261. noPlacesLabel.TextColor3 = Color3.new(1, 1, 1)
  262.  
  263. noPlacesLabel.Font = Enum.Font.SourceSansItalic
  264.  
  265. noPlacesLabel.TextSize = 18
  266.  
  267. noPlacesLabel.Text = "No sub-places found."
  268.  
  269. noPlacesLabel.Parent = scrollingFrame
  270.  
  271. else
  272.  
  273. for _, place in ipairs(allPlaces) do
  274.  
  275. createSubPlaceEntry(place)
  276.  
  277. end
  278.  
  279. end
  280.  
  281.  
  282.  
  283. -- Adjust canvas size based on content
  284.  
  285. scrollingFrame.CanvasSize = UDim2.new(0, 0, 0, listLayout.AbsoluteContentSize.Y)
  286.  
  287. else
  288.  
  289. -- Error fetching places
  290.  
  291. local errorLabel = Instance.new("TextLabel")
  292.  
  293. errorLabel.Size = UDim2.new(1, 0, 0, 40)
  294.  
  295. errorLabel.BackgroundTransparency = 1
  296.  
  297. errorLabel.TextColor3 = Color3.new(1, 0, 0)
  298.  
  299. errorLabel.Font = Enum.Font.SourceSansBold
  300.  
  301. errorLabel.TextSize = 18
  302.  
  303. errorLabel.Text = "Error fetching sub-places."
  304.  
  305. errorLabel.Parent = scrollingFrame
  306.  
  307. end
  308.  
  309.  
  310.  
  311. showButton.Text = "Show Sub-Places"
  312.  
  313. showButton.Active = true
  314.  
  315. showButton.AutoButtonColor = true
  316.  
  317. end)
  318.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement