Advertisement
HowToRoblox

StandHandler

Mar 18th, 2022
4,889
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 1 0
  1. local nameLabel = script.Parent:WaitForChild("NamePart"):WaitForChild("NameGui"):WaitForChild("NameLabel")
  2. nameLabel.Text = "Unclaimed!"
  3. local itemsScroller = script.Parent:WaitForChild("ItemsPart"):WaitForChild("ItemsGui"):WaitForChild("ItemsScroller")
  4.  
  5. local proximityPrompt = Instance.new("ProximityPrompt", script.Parent.NamePart)
  6. proximityPrompt.HoldDuration = 1
  7. proximityPrompt.ActionText = "Hold E to Claim!"
  8. proximityPrompt.UIOffset = Vector2.new(0, 2)
  9. proximityPrompt.RequiresLineOfSight = false
  10. proximityPrompt.Name = "StandProximityPrompt"
  11.  
  12.  
  13. local http = game:GetService("HttpService")
  14.  
  15. local url = "https://catalog.roproxy.com/v1/search/items/details?Category=3&CreatorName="
  16.  
  17.  
  18. proximityPrompt.Triggered:Connect(function(plr)
  19.  
  20.     local data = http:JSONDecode(http:GetAsync(url .. plr.Name)).data
  21.  
  22.     if data then
  23.  
  24.         game.ReplicatedStorage.RemoteEvent:FireClient(plr)
  25.  
  26.         nameLabel.Text = plr.Name .. "'s Stand"
  27.  
  28.         proximityPrompt.Enabled = false
  29.  
  30.         table.sort(data,
  31.             function(a,b)
  32.                 return a.price < b.price
  33.             end
  34.         )
  35.  
  36.  
  37.         for i, item in pairs(data) do
  38.  
  39.             local newButton = script.DonateButton:Clone()
  40.             newButton.Text = item.price .. "R$"
  41.  
  42.             local id = Instance.new("IntValue", newButton)
  43.             id.Value = item.id
  44.  
  45.             newButton.Parent = itemsScroller
  46.  
  47.             itemsScroller.CanvasSize = UDim2.new(0, itemsScroller.UIListLayout.AbsoluteContentSize.X, 0, 0)
  48.         end
  49.  
  50.  
  51.         game.Players.PlayerRemoving:Connect(function(plrLeaving)
  52.  
  53.             if plr == plrLeaving then
  54.  
  55.                 nameLabel.Text = "Unclaimed!"
  56.                 proximityPrompt.Enabled = true
  57.  
  58.                 for i, child in pairs(itemsScroller:GetChildren()) do
  59.                     if child:IsA("TextButton") then child:Destroy() end
  60.                 end
  61.             end
  62.         end)
  63.     end
  64. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement