Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local GuiCreated = 0
- local children = script.Parent.Purchases:GetChildren()
- for i = 1, #children do
- print(i, children[i].Name)
- end
- local s = 0
- local r = 0
- local p = 1
- while GuiCreated == 0 do
- local OwnerDir = script.Parent:FindFirstChild("Owner")
- game.StarterGui.ResetPlayerGuiOnSpawn = false
- if OwnerDir then
- for i,v in pairs(script.Parent.Purchases:GetChildren()) do
- local Player = script.Parent.Owner.Value
- if v ~= nil then
- if Player ~= nil then
- local Player = script.Parent.Owner.Value
- local PlayerDir = game.Players:FindFirstChild(Player)
- local Gui = PlayerDir.PlayerGui.ScreenGui
- local Page = Gui.TycoonFrame.Gui.Purchases:FindFirstChild("page" .. p)
- if (Page == nil) then
- PageNum = Instance.new("Frame",Gui.TycoonFrame.Gui.Purchases)
- PageNum.Name = "page" .. p
- end
- if (p >= 2) then
- PageNum.Visible = false
- end
- local RowIncrement = 185*r
- local SlotIncrement = 145*s
- local GuiIncrement = UDim2.new(0,5+SlotIncrement,0,10+RowIncrement) Slot = Instance.new("Frame",Gui.TycoonFrame.Gui.Purchases["page" .. p])
- if v:FindFirstChild("Buyable") then
- if v.Buyable.Value == 0 then
- Slot.Visible = false
- end
- else
- print("No Buyable Value found for item " .. v.Name)
- end
- Slot.Name = v.Name
- Slot.Size = UDim2.new(0,145,0,185)
- Slot.Position = GuiIncrement
- Button = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
- Button.Name = "BuyButton"
- Button.Text = "Buy"
- Button.Size = UDim2.new(0, 100,0, 25)
- Button.Position = UDim2.new(0,23,0,150)
- Image = Instance.new("ImageLabel",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
- Image.Name = "Image"
- Image.Size = UDim2.new(0, 100,0, 100)
- Image.Position = UDim2.new(0,23,0,45)
- if v:FindFirstChild("Image") then
- Image.Image = v.Image.Value
- else
- print("No Image Value found for item " .. v.Name)
- end
- Cost = Instance.new("TextLabel",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
- Cost.Name = "CostLabel"
- if v:FindFirstChild("Price") then
- Cost.Text = "Price: " .. v.Price.Value
- else
- print("No Cost Value found for item " .. v.Name)
- end
- Cost.Position = UDim2.new(0,70,0,35)
- NameLab = Instance.new("TextLabel",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
- NameLab.Name = "NameLabel"
- NameLab.Text = v.Name
- NameLab.Position = UDim2.new(0,70,0,15)
- Value = Instance.new("IntValue", Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
- Value.Name = "ItemPrice"
- if v:FindFirstChild("Price") then
- Value.Value = v.Price.Value
- else
- print("Error! No price has been found for item " .. v.Name .. "! The Tycoon will stop working if the item is bought")
- end
- local CanUpgrade = v:FindFirstChild("Upgradeable")
- if CanUpgrade ~= nil then
- if CanUpgrade.Value == true then
- Upgrade = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases["page" .. p][v.Name])
- Upgrade.Name = "UpgradeButton"
- Upgrade.Text = "Upgrade"
- Upgrade.Size = UDim2.new(0, 100,0, 25)
- Upgrade.Position = UDim2.new(0,23,0,150)
- Upgrade.Visible = false
- end
- end
- s = s + 1
- if r == 2 and s == 4 then
- s = 0
- r = 0
- print("New Page")
- if (p == 1)then
- NextButton = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases)
- NextButton.Name = "NextButton"
- NextButton.Text = "Next Page"
- NextButton.Size = UDim2.new(0, 100,0, 25)
- NextButton.Position = UDim2.new(0,485,0,600)
- PreviousButton = Instance.new("TextButton",Gui.TycoonFrame.Gui.Purchases)
- PreviousButton.Name = "PreviousButton"
- PreviousButton.Text = "Previous Page"
- PreviousButton.Size = UDim2.new(0, 100,0, 25)
- PreviousButton.Position = UDim2.new(0,7,0,600)
- Gui.TycoonFrame.Gui.Purchases.PageHandler.Disabled = false
- end
- p = p + 1
- Gui.TycoonFrame.Gui.Purchases.Pages.Value = p
- end
- if s == 4 then
- s = 0
- r = r + 1
- end
- end
- end
- end
- GuiCreated = 1
- end
- wait(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment