95Roadkill

Roblox Tycoon, Gui Creation.

Oct 22nd, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.37 KB | None | 0 0
  1. local GuiCreated = 0
  2. local children = script.Parent.Purchases:GetChildren()
  3.  
  4. for i = 1, #children do
  5.     print(i, children[i].Name)
  6. end
  7.  
  8. local s = 0    
  9. local r = 0
  10. local p = 1
  11. while GuiCreated == 0 do
  12.     local OwnerDir = script.Parent:FindFirstChild("Owner")
  13.     game.StarterGui.ResetPlayerGuiOnSpawn = false
  14.     if OwnerDir then   
  15.         for i,v in pairs(script.Parent.Purchases:GetChildren()) do
  16.             local Player = script.Parent.Owner.Value
  17.             if v ~= nil then
  18.                 if Player ~= nil then
  19.                 local Player = script.Parent.Owner.Value
  20.                 local PlayerDir = game.Players:FindFirstChild(Player)
  21.                 local Gui = PlayerDir.PlayerGui.ScreenGui
  22.                         local Page = Gui.TycoonFrame.Gui.Purchases:FindFirstChild("page" .. p)
  23.                         if (Page == nil) then          
  24.                             PageNum = Instance.new("Frame",Gui.TycoonFrame.Gui.Purchases)
  25.                             PageNum.Name = "page" .. p                         
  26.                         end
  27.                         if (p >= 2) then
  28.                             PageNum.Visible = false
  29.                         end
  30.                         local RowIncrement = 185*r
  31.                             local SlotIncrement = 145*s
  32.                             local GuiIncrement = UDim2.new(0,5+SlotIncrement,0,10+RowIncrement)                                                         Slot = Instance.new("Frame",Gui.TycoonFrame.Gui.Purchases["page" .. p])
  33.                         if v:FindFirstChild("Buyable") then
  34.                             if v.Buyable.Value == 0 then
  35.                                 Slot.Visible = false                           
  36.                             end
  37.                         else
  38.                             print("No Buyable Value found for item " .. v.Name)
  39.                         end                    
  40.                         Slot.Name = v.Name
  41.                         Slot.Size = UDim2.new(0,145,0,185) 
  42.                         Slot.Position = GuiIncrement
  43.                         Button = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
  44.                         Button.Name = "BuyButton"
  45.                         Button.Text = "Buy"
  46.                         Button.Size = UDim2.new(0, 100,0, 25)
  47.                         Button.Position = UDim2.new(0,23,0,150)
  48.                         Image = Instance.new("ImageLabel",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
  49.                         Image.Name = "Image"
  50.                         Image.Size = UDim2.new(0, 100,0, 100)
  51.                         Image.Position = UDim2.new(0,23,0,45)
  52.                         if v:FindFirstChild("Image") then
  53.                             Image.Image = v.Image.Value
  54.                         else
  55.                             print("No Image Value found for item " .. v.Name)
  56.                         end
  57.                         Cost = Instance.new("TextLabel",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
  58.                         Cost.Name = "CostLabel"
  59.                         if v:FindFirstChild("Price") then
  60.                             Cost.Text = "Price: " .. v.Price.Value
  61.                         else
  62.                             print("No Cost Value found for item " .. v.Name)
  63.                         end
  64.                         Cost.Position = UDim2.new(0,70,0,35)
  65.                         NameLab = Instance.new("TextLabel",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
  66.                         NameLab.Name = "NameLabel"
  67.                         NameLab.Text = v.Name
  68.                         NameLab.Position = UDim2.new(0,70,0,15)
  69.                         Value = Instance.new("IntValue", Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
  70.                         Value.Name = "ItemPrice"
  71.                         if v:FindFirstChild("Price") then
  72.                             Value.Value = v.Price.Value
  73.                         else
  74.                             print("Error! No price has been found for item " .. v.Name .. "! The Tycoon will stop working if the item is bought")
  75.                         end
  76.                         local CanUpgrade = v:FindFirstChild("Upgradeable")
  77.                         if CanUpgrade ~= nil then
  78.                             if CanUpgrade.Value == true then
  79.                                 Upgrade = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
  80.                                 Upgrade.Name = "UpgradeButton"
  81.                                 Upgrade.Text = "Upgrade"
  82.                                 Upgrade.Size = UDim2.new(0, 100,0, 25)
  83.                                 Upgrade.Position = UDim2.new(0,23,0,150)
  84.                                 Upgrade.Visible = false
  85.                             end
  86.                         end
  87.                         s = s + 1
  88.                         if r == 2 and s == 4 then
  89.                             s = 0
  90.                             r = 0
  91.                             print("New Page")
  92.                             if (p == 1)then                            
  93.                                 NextButton = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases)
  94.                                 NextButton.Name = "NextButton"
  95.                                 NextButton.Text = "Next Page"
  96.                                 NextButton.Size = UDim2.new(0, 100,0, 25)
  97.                                 NextButton.Position = UDim2.new(0,485,0,600)
  98.                                 PreviousButton = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases)
  99.                                 PreviousButton.Name = "PreviousButton"
  100.                                 PreviousButton.Text = "Previous Page"
  101.                                 PreviousButton.Size = UDim2.new(0, 100,0, 25)
  102.                                 PreviousButton.Position = UDim2.new(0,7,0,600)                         
  103.                                 Gui.TycoonFrame.Gui.Purchases.PageHandler.Disabled = false
  104.                             end
  105.                             p = p + 1
  106.                             Gui.TycoonFrame.Gui.Purchases.Pages.Value = p  
  107.                         end                    
  108.                         if s == 4 then
  109.                             s = 0
  110.                             r = r + 1
  111.                         end
  112.                 end
  113.             end
  114.         end
  115.         GuiCreated = 1
  116.     end
  117.     wait(1)
  118. end
Advertisement
Add Comment
Please, Sign In to add comment