Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local http = game:GetService("HttpService")
- local baseUrl = "https://catalog.roproxy.com/v1/search/items/details?Category=3&Subcategory=13&Limit=30&CreatorName=%s&cursor=%s"
- local ProximityPromptService = game:GetService("ProximityPromptService")
- local Stands = game.Workspace.ShopStands
- local ShopEvent = game.ReplicatedStorage.ShopEvent
- local ProximityPromptUpdater = game.ReplicatedStorage.ProximityPromptUpdater
- local UnclaimEvent = game.ReplicatedStorage.UnclaimEvent
- local RefreshEvent = game.ReplicatedStorage.RefreshEvent
- local StandColorChangeEvent = game.ReplicatedStorage.StandColorChangeEvent
- local debounce = true
- local atestnumber = 0
- local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
- tshirts = tshirts or {}
- cursor = cursor or ""
- local requestUrl = baseUrl:format(username, cursor)
- local success, result = pcall(function()
- -- print(http:GetAsync(requestUrl))
- return http:GetAsync(requestUrl)
- end)
- if success then
- if result then
- local success2, result2 = pcall(function()
- -- print(http:JSONDecode(result))
- -- print(http:JSONEncode(result)) --this or the other
- return http:JSONDecode(result)
- end)
- if success2 then
- if result2 then
- for _, tshirt in ipairs(result2.data) do
- -- print(tshirt)
- table.insert(tshirts, tshirt.id)
- -- table.insert(tshirts, tshirt.price)
- end
- cursor = result2.nextPageCursor
- if cursor then
- return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
- else
- return tshirts
- end
- end
- else
- warn(result)
- end
- end
- else
- warn(result)
- end
- end
- local function getUserGeneratedTShirtsPrices(username, tshirts, cursor)
- tshirts = tshirts or {}
- cursor = cursor or ""
- local requestUrl = baseUrl:format(username, cursor)
- local success, result = pcall(function()
- -- print(http:GetAsync(requestUrl))
- return http:GetAsync(requestUrl)
- end)
- if success then
- if result then
- local success2, result2 = pcall(function()
- -- print(http:JSONDecode(result))
- -- print(http:JSONEncode(result))
- return http:JSONDecode(result)
- end)
- if success2 then
- if result2 then
- for _, tshirt in ipairs(result2.data) do
- table.insert(tshirts, tshirt.price)
- end
- cursor = result2.nextPageCursor
- if cursor then
- return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
- else
- return tshirts
- end
- end
- else
- warn(result)
- end
- end
- else
- warn(result)
- end
- end
- local dictionary = {}
- game.Players.PlayerAdded:Connect(function(Player)
- -- print(Player)
- local PlayerStandCheck = Instance.new("BoolValue")
- PlayerStandCheck.Parent = Player
- PlayerStandCheck.Value = false
- PlayerStandCheck.Name = "PlayerStandCheck"
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- stands:FindFirstChild("PricePart").Attachment.ProximityPrompt.Triggered:Connect(function(Player)
- if stands:FindFirstChild("Owned").Value == false and stands:FindFirstChild("PlayerName").Value == "" and Player:FindFirstChild("PlayerStandCheck").Value ~= true then -- and debounce
- Player:FindFirstChild("PlayerStandCheck").Value = true
- stands:FindFirstChild("Owned").Value = true
- stands:FindFirstChild("PlayerName").Value = Player.Name
- stands:FindFirstChild("DescriptionPart").SurfaceGui.PlayerName.Text = Player.Name .. "'s stand"
- stands:FindFirstChild("DescriptionPart").SurfaceGui.PriceRaised.Text = Player.leaderstats["Raised 💰"].Value .. " raised"
- stands:FindFirstChild("DescriptionPart").SurfaceGui.PriceRaised.Visible = true
- local Song = "Level Up"
- ShopEvent:FireClient(Player,Song)
- ProximityPromptUpdater:FireAllClients(Player)
- wait(.5)
- local username = Player.Name --"ignaury"
- local userTShirts = getUserGeneratedTShirtsRecursive(username)
- -- print(userTShirts) -- it brings a table id thingy
- -- print(#userTShirts) --3
- -- print(table.concat(userTShirts, " "))
- wait(.1)
- local price = getUserGeneratedTShirtsPrices(username)
- -- print(table.concat(price, " "))
- -- local randomnumbers = {(unpack(price))}
- -- print(randomnumbers)
- -- print(price[i])
- -- print(price[1])
- -- print(price[2])
- -- print(price[0])
- --print(price)
- task.wait(.5)
- local number = #userTShirts or nil
- -- print(userTShirts)
- -- print(userTShirts[1])
- -- print(userTShirts[2])
- local prices = #price
- if #userTShirts ~= 0 and #userTShirts ~= nil then
- stands:FindFirstChild("PricePart").SurfaceGui.Enabled = true
- --print(userTShirts.price[i])
- --print(price == userTShirts)
- local TextLocation = game:GetService("ServerStorage")
- local ButtonFolder = Instance.new("Folder")
- ButtonFolder.Parent = TextLocation
- ButtonFolder.Name = Player.Name
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands:FindFirstChild("Owned").Value == true and stands:FindFirstChild("PlayerName").Value == Player.Name and Player:FindFirstChild("PlayerStandCheck").Value == true then
- for i = 1, number do
- -- print("Cloning depending on the number")
- local TextClone = TextLocation.ButtonForClone.TextButton:Clone()
- TextClone.Parent = ButtonFolder
- --TextClone.Parent = stands:FindFirstChild("PricePart").SurfaceGui.Frame.ScrollingFrame
- local PriceText = TextClone
- -- prices += #price
- -- PriceText.Text = price
- --local randomnumber = unpack(userTShirts)
- --[[ for i, item in pairs (userTShirts) do
- print(item)
- print(i)
- -- PriceText.Text = item
- if i == #userTShirts then
- break
- end
- end --]]
- atestnumber = atestnumber + 1
- -- print(atestnumber)
- PriceText.Text = price[atestnumber] .. "$"
- PriceText.Price.Value = price[atestnumber]
- PriceText:FindFirstChild("id").Value = userTShirts[atestnumber]
- --PriceText.Name = "ImageButton" .. atestnumber
- if atestnumber == #userTShirts then
- for i,newbuttons in ipairs(ButtonFolder:GetChildren()) do
- if newbuttons:IsA("TextButton") then
- local newatestnumber = 0
- newatestnumber = newatestnumber + 1
- --print(i,newbuttons)
- if i == #price then --tonumber(math.ceil(newbuttons.Text)) --<= tonumber(math.ceil(newbuttons.Text))
- dictionary = ButtonFolder:GetChildren()
- for _, value in pairs(ButtonFolder:GetChildren()) do
- --dictionary[value.Text] = value.Text;
- --print(unpack(dictionary))
- -- print(value.Text)
- -- print(unpack(dictionary))
- -- print(value)
- -- print(unpack(ButtonFolder:GetChildren()))
- value.Parent = stands:FindFirstChild("PricePart").SurfaceGui.Frame.ScrollingFrame
- end
- -- runs once to clean and reset the values back to their default value!!
- game.ServerStorage:FindFirstChild(Player.Name):Destroy()
- atestnumber = 0
- newatestnumber = 0
- --[[ for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands:FindFirstChild("Owned").Value == true and stands:FindFirstChild("PlayerName").Value == Player.Name then
- local buttonsinshop = stands.PricePart.SurfaceGui.Frame.ScrollingFrame:GetDescendants()
- -- print(buttonsinshop[1])
- for i,v in pairs(buttonsinshop) do
- if v:IsA("IntValue") and v.Name == "Price" then
- -- print(v)
- -- print(v.Value)
- --table.sort(v)
- -- print(table.sort(v))
- -- v = {}
- --i = i + 1
- -- table.insert(v, v[i])
- print(i,v)
- print(v.Value)
- local theunpacking,theunpacking2 = table.unpack(buttonsinshop)
- print(theunpacking2)
- -- local tableindex = 0
- -- tableindex = i
- -- print(tableindex)
- --tostring(print(i.." - "..v))
- -- print(v[1])
- -- print(v[2])
- end
- end
- end
- end
- end --]]
- --print(newbuttons.Text)
- -- newbuttons.Parent = stands:FindFirstChild("PricePart").SurfaceGui.Frame.ScrollingFrame
- end
- end
- end
- else
- end
- end
- end
- end
- end
- else
- -- print(Player.Name .. " has no tshirts")
- end
- elseif stands:FindFirstChild("Owned").Value == true and stands:FindFirstChild("PlayerName").Value == Player.Name then
- -- print("Its Your Stand")
- local Song = "Open Shop"
- ShopEvent:FireClient(Player,Song)
- elseif stands:FindFirstChild("Owned").Value == false and stands:FindFirstChild("PlayerName").Value == "" then
- local Song = "No"
- ShopEvent:FireClient(Player,Song)
- -- print("you already have a stand")
- end
- end)
- end
- end
- Player.CharacterAdded:Connect(function(Character)
- task.wait(.5)
- -- print("ProximityPromptUpdater fired")
- ProximityPromptUpdater:FireAllClients(Player)
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(Player)
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
- stands.TextPart.SurfaceGui:FindFirstChild("TextLabel").Text = "Your Text Here"
- stands.DescriptionPart.SurfaceGui:FindFirstChild("PlayerName").Text = "unclaimed"
- stands.DescriptionPart.SurfaceGui:FindFirstChild("PriceRaised").Visible = false
- stands:FindFirstChild("PricePart").Attachment.ProximityPrompt.Enabled = true
- stands:FindFirstChild("Owned").Value = false
- stands:FindFirstChild("PricePart").SurfaceGui.Enabled = false
- for i,textbuttons in pairs(Stands:GetDescendants()) do
- if textbuttons:IsA("TextButton") and textbuttons.Name == "TextButton" then
- local PlayerName = textbuttons.Parent.Parent.Parent.Parent.Parent.PlayerName.Value
- if PlayerName == Player.Name then
- textbuttons:Destroy()
- -- print(textbuttons.Text)
- else
- -- print("this shouldnt run i think")
- end
- end
- end
- stands:FindFirstChild("PlayerName").Value = ""
- ProximityPromptUpdater:FireAllClients(Player)
- -- print("Someone Left")
- end
- end
- end
- end)
- -- Update The Text thats Applied
- ShopEvent.OnServerEvent:Connect(function(Player,DescriptionBoardText)
- --print(DescriptionBoardText)
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
- stands.TextPart.SurfaceGui:FindFirstChild("TextLabel").Text = DescriptionBoardText
- end
- end
- end
- end)
- RefreshEvent.OnServerEvent:Connect(function(Player)
- -- print(Player)
- for i,textbuttons in pairs(Stands:GetDescendants()) do
- if textbuttons:IsA("TextButton") and textbuttons.Name == "TextButton" then
- local PlayerName = textbuttons.Parent.Parent.Parent.Parent.Parent.PlayerName.Value
- if PlayerName == Player.Name then
- -- print(textbuttons)
- textbuttons:Destroy()
- -- wait(1)
- else
- end
- end
- end
- -- print("start the new button update")
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
- local username = Player.Name -- "ignaury"
- local userTShirts = getUserGeneratedTShirtsRecursive(username)
- wait(.1)
- local price = getUserGeneratedTShirtsPrices(username)
- task.wait(.5)
- local number = #userTShirts or nil
- if #userTShirts ~= 0 and #userTShirts ~= nil then -- did ~= nil not nessary
- stands:FindFirstChild("PricePart").SurfaceGui.Enabled = true
- local TextLocation = game:GetService("ServerStorage")
- local ButtonFolder = Instance.new("Folder")
- ButtonFolder.Parent = TextLocation
- ButtonFolder.Name = Player.Name
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands:FindFirstChild("Owned").Value == true and stands:FindFirstChild("PlayerName").Value == Player.Name and Player:FindFirstChild("PlayerStandCheck").Value == true then
- for i = 1, number do
- -- print("Cloning depending on the number")
- local TextClone = TextLocation.ButtonForClone.TextButton:Clone()
- TextClone.Parent = ButtonFolder
- local PriceText = TextClone
- atestnumber = atestnumber + 1
- PriceText.Text = price[atestnumber] .. "$"
- PriceText.Price.Value = price[atestnumber]
- PriceText:FindFirstChild("id").Value = userTShirts[atestnumber]
- if atestnumber == #userTShirts then
- for i,newbuttons in ipairs(ButtonFolder:GetChildren()) do
- if newbuttons:IsA("TextButton") then
- local newatestnumber = 0
- newatestnumber = newatestnumber + 1
- if i == #price then
- dictionary = ButtonFolder:GetChildren()
- for _, value in pairs(ButtonFolder:GetChildren()) do
- value.Parent = stands:FindFirstChild("PricePart").SurfaceGui.Frame.ScrollingFrame
- end
- -- runs once to clean and reset the values back to their default value!!
- game.ServerStorage:FindFirstChild(Player.Name):Destroy()
- atestnumber = 0
- newatestnumber = 0
- wait(.1)
- -- ProximityPromptUpdater:FireClient(Player)
- end
- end
- end
- else
- end
- end
- end
- end
- end
- else
- end
- end
- end
- end
- end)
- UnclaimEvent.OnServerEvent:Connect(function(Player)
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
- stands.TextPart.SurfaceGui:FindFirstChild("TextLabel").Text = "Your Text Here"
- stands.DescriptionPart.SurfaceGui:FindFirstChild("PlayerName").Text = "unclaimed"
- stands.DescriptionPart.SurfaceGui:FindFirstChild("PriceRaised").Visible = false
- stands:FindFirstChild("PricePart").Attachment.ProximityPrompt.Enabled = true
- stands:FindFirstChild("Owned").Value = false
- stands:FindFirstChild("PricePart").SurfaceGui.Enabled = false
- for i,textbuttons in pairs(Stands:GetDescendants()) do
- if textbuttons:IsA("TextButton") and textbuttons.Name == "TextButton" then
- local PlayerName = textbuttons.Parent.Parent.Parent.Parent.Parent.PlayerName.Value
- if PlayerName == Player.Name then
- textbuttons:Destroy()
- else
- end
- end
- end
- stands:FindFirstChild("PlayerName").Value = ""
- Player:FindFirstChild("PlayerStandCheck").Value = false
- UnclaimEvent:FireClient(Player)
- ProximityPromptUpdater:FireAllClients(Player)
- end
- end
- end
- end)
- StandColorChangeEvent.OnServerEvent:Connect(function(Player,ButtonPrice)
- print(ButtonPrice)
- for i,stands in pairs(Stands:GetDescendants()) do
- if stands:IsA("Model") and stands.Name == "ShopStand" then
- if stands.Owned.Value == true and stands.PlayerName.Value == Player.Name then
- if ButtonPrice == 0 and Player.leaderstats["Raised 💰"].Value >= 0 then
- print("starter button pressed")
- elseif ButtonPrice == 1000 and Player.leaderstats["Raised 💰"].Value >= 1000 then
- print("button 1k pressed")
- elseif ButtonPrice == 10000 and Player.leaderstats["Raised 💰"].Value >= 10000 then
- print("button 10k pressed")
- elseif ButtonPrice == 100000 and Player.leaderstats["Raised 💰"].Value >= 100000 then
- print("button 100k pressed")
- elseif ButtonPrice == 1000000 and Player.leaderstats["Raised 💰"].Value >= 1000000 then
- print("button 1000k or 1 milion pressed")
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement