Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Gui loader
- -- Yikes, this scirpt is I think one of the longest I've ever writen.
- local player = game.Players.LocalPlayer
- local ReplicatedStorage = game:GetService('ReplicatedStorage')
- local products = require(ReplicatedStorage:WaitForChild('Products'))
- local itemsArray = require(ReplicatedStorage:WaitForChild('Items'))
- local DevProducts = products['DevProducts']
- local GamePasses = products['GamePasses']
- local UpdateTotalProfit = ReplicatedStorage.GUI:WaitForChild('UpdateTotalProfit')
- local MessagePrefix = 'This game has made '
- local UI = player.PlayerGui:WaitForChild('UI')
- local DevProdFrame = UI.Shop.Coins.Items
- local GamePassFrame = UI.Shop.Passes.Items
- local ShopOpened = UI.Shop.Opened
- local UpgradeOpened = UI.Items.Opened
- local TweeningShop = false
- local TweeningUpgrade = false
- local BuyRemote = ReplicatedStorage.GUI:WaitForChild('BuyItem')
- local MarketplaceService = game:GetService("MarketplaceService")
- local PlayerWaitEvent = ReplicatedStorage.GUI:WaitForChild('PlayerWait')
- local AnnounceEvent = ReplicatedStorage.GUI:WaitForChild('Announce')
- local TimerEvent = ReplicatedStorage.GUI:WaitForChild('Timer')
- -- ANNOUNCE HANDLER --
- local function announce(title, message)
- warn('Recieved Announcement, '..title..' & '..message)
- local AnnouncementFrame = UI.Announcement
- AnnouncementFrame.Title.Text = title
- AnnouncementFrame.Message.Text = message
- AnnouncementFrame.Visible = true
- AnnouncementFrame.Position = UDim2.new(0, -300,0.5, -75)
- AnnouncementFrame:TweenPosition(UDim2.new(0.5, -150,0.5, -75), 'Out', 'Bounce', 1)
- wait(3)
- AnnouncementFrame:TweenPosition(UDim2.new(1, 0,0.5, -75), 'In', 'Bounce', 1)
- wait(1)
- AnnouncementFrame.Visible = false
- end
- AnnounceEvent.OnClientEvent:Connect(announce)
- -- TIMER HANDLER --
- local function timer(seconds)
- warn('Starting Timer on Chient for '..tostring(seconds)..' seconds')
- local TimerFrame = UI.timer
- TimerFrame.Position = UDim2.new(0.5, -100,0, -110)
- TimerFrame.Visible = true
- TimerFrame:TweenPosition(UDim2.new(0.5, -100, 0, 0), 'Out', 'Bounce', 1)
- TimerFrame.Timer.Text = 'LOADING'
- TimerFrame.Timer.Shadow.Text = 'LOADING'
- wait(1)
- for i=seconds, 0, -1 do
- TimerFrame.Timer.Text = i
- TimerFrame.Timer.Shadow.Text = i
- wait(1)
- end
- TimerFrame.Timer.Text = 'DONE'
- TimerFrame.Timer.Shadow.Text = 'DONE'
- TimerFrame:TweenPosition(UDim2.new(0.5, -100, 0, -110), 'Out', 'Bounce', 1)
- wait(1)
- TimerFrame.Visible = false
- end
- TimerEvent.OnClientEvent:Connect(timer)
- -------------------------------------------------
- function addComas(str)
- str = tostring(str)
- return #str % 3 == 0 and str:reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or str:reverse():gsub("(%d%d%d)", "%1,"):reverse()
- end
- function round(num, numDecimalPlaces)
- return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
- end
- local function UpdateClient(amount)
- local Shop = UI.Shop
- Shop.Profit.Text = MessagePrefix..addComas(round(amount, 0))..'R$'
- end
- -- GUI LOADERS --
- local function setPlayerInformation()
- local PlayerInfo = UI.PlayerInformation
- PlayerInfo.NameLabel.Text = player.Name
- PlayerInfo.NameLabel.Shadow.Text = player.Name
- PlayerInfo.PlayerIcon.Image = game.Players:GetUserThumbnailAsync(player.UserId, "HeadShot", "Size352x352")
- end
- local function LoadItems()
- local Items = UI.Items
- local ItemNumber1, ItemNumber2, ItemNumber3 = Items.Item1, Items.Item2, Items.Item3
- -- ITEM #1 --
- ItemNumber1.Icon.Image = itemsArray['Item1']['Icon']
- ItemNumber1.Title.Text = itemsArray['Item1']['Name']
- ItemNumber1.Title.Shadow.Text = itemsArray['Item1']['Name']
- ItemNumber1.Cost.Text = itemsArray['Item1']['Price']
- ItemNumber1.Cost.Shadow.Text = itemsArray['Item1']['Price']
- ItemNumber1.String.Value = itemsArray['Item1']['String']
- -- ITEM #2 --
- ItemNumber2.Icon.Image = itemsArray['Item2']['Icon']
- ItemNumber2.Title.Text = itemsArray['Item2']['Name']
- ItemNumber2.Title.Shadow.Text = itemsArray['Item2']['Name']
- ItemNumber2.Cost.Text = itemsArray['Item2']['Price']
- ItemNumber2.Cost.Shadow.Text = itemsArray['Item2']['Price']
- ItemNumber2.String.Value = itemsArray['Item2']['String']
- -- ITEM #3 --
- ItemNumber3.Icon.Image = itemsArray['Item3']['Icon']
- ItemNumber3.Title.Text = itemsArray['Item3']['Name']
- ItemNumber3.Title.Shadow.Text = itemsArray['Item3']['Name']
- ItemNumber3.Cost.Text = itemsArray['Item3']['Price']
- ItemNumber3.Cost.Shadow.Text = itemsArray['Item3']['Price']
- ItemNumber3.String.Value = itemsArray['Item3']['String']
- end
- local function LoadShop()
- local Shop = UI.Shop
- local Coins = Shop.Coins
- local Passes = Shop.Passes
- local DevProduct1, DevProduct2, DevProduct3 = Coins.Items.DevProduct1, Coins.Items.DevProduct2, Coins.Items.DevProduct3
- local GamePass1, GamePass2, GamePass3 = Passes.Items.GamePass1, Passes.Items.GamePass2, Passes.Items.GamePass3
- -- DEV PRODUCT #1 --
- DevProduct1.Title.Text = DevProducts['DevProduct1']['Name']
- DevProduct1.Title.Shadow.Text = DevProducts['DevProduct1']['Name']
- DevProduct1.Costs.Text = DevProducts['DevProduct1']['Price']
- DevProduct1.Costs.Shadow.Text = DevProducts['DevProduct1']['Price']
- DevProduct1.Icon.Image = DevProducts['DevProduct1']['Icon']
- DevProduct1.Id.Value = DevProducts['DevProduct1']['ID']
- -- DEV PRODUCT #2 --
- DevProduct2.Title.Text = DevProducts['DevProduct2']['Name']
- DevProduct2.Title.Shadow.Text = DevProducts['DevProduct2']['Name']
- DevProduct2.Costs.Text = DevProducts['DevProduct2']['Price']
- DevProduct2.Costs.Shadow.Text = DevProducts['DevProduct2']['Price']
- DevProduct2.Icon.Image = DevProducts['DevProduct2']['Icon']
- DevProduct2.Id.Value = DevProducts['DevProduct2']['ID']
- -- DEV PRODUCT #3 --
- DevProduct3.Title.Text = DevProducts['DevProduct3']['Name']
- DevProduct3.Title.Shadow.Text = DevProducts['DevProduct3']['Name']
- DevProduct3.Costs.Text = DevProducts['DevProduct3']['Price']
- DevProduct3.Costs.Shadow.Text = DevProducts['DevProduct3']['Price']
- DevProduct3.Icon.Image = DevProducts['DevProduct3']['Icon']
- DevProduct3.Id.Value = DevProducts['DevProduct3']['ID']
- -- GAME PASS #1 --
- GamePass1.Title.Text = GamePasses['GamePass1']['Name']
- GamePass1.Title.Shadow.Text = GamePasses['GamePass1']['Name']
- GamePass1.Costs.Text = GamePasses['GamePass1']['Price']
- GamePass1.Costs.Shadow.Text = GamePasses['GamePass1']['Price']
- GamePass1.Icon.Image = GamePasses['GamePass1']['Icon']
- GamePass1.Id.Value = GamePasses['GamePass1']['ID']
- -- GAME PASS #2 --
- GamePass2.Title.Text = GamePasses['GamePass2']['Name']
- GamePass2.Title.Shadow.Text = GamePasses['GamePass2']['Name']
- GamePass2.Costs.Text = GamePasses['GamePass2']['Price']
- GamePass2.Costs.Shadow.Text = GamePasses['GamePass2']['Price']
- GamePass2.Icon.Image = GamePasses['GamePass2']['Icon']
- GamePass2.Id.Value = GamePasses['GamePass2']['ID']
- -- GAME PASS #3 --
- GamePass3.Title.Text = GamePasses['GamePass3']['Name']
- GamePass3.Title.Shadow.Text = GamePasses['GamePass3']['Name']
- GamePass3.Costs.Text = GamePasses['GamePass3']['Price']
- GamePass3.Costs.Shadow.Text = GamePasses['GamePass3']['Price']
- GamePass3.Icon.Image = GamePasses['GamePass3']['Icon']
- GamePass3.Id.Value = GamePasses['GamePass3']['ID']
- end
- local function UpdateValues()
- local leaderstats = player:WaitForChild('leaderstats')
- local wins = leaderstats.Wins
- local coins = leaderstats.Coins
- local PlayerInformation = UI.PlayerInformation
- spawn(function()
- while wait(0.5) do
- PlayerInformation.WinCounter.Text = ("TOTAL WINS: ".. wins.Value)
- PlayerInformation.CoinCounter.Text = ('COINS: '.. coins.Value)
- UI.Items.CoinStatus.Text = 'You currently have '.. coins.Value ..' coins'
- UI.Items.CoinStatus.Shadow.Text = 'You currently have '.. coins.Value ..' coins'
- end
- end)
- end
- local function shop(bool)
- if bool == true then --Open Shop
- UI.Shop.Visible = true
- UI.Shop.Position = UDim2.new(0.5, -353,1, 0)
- UI.Shop:TweenPosition(UDim2.new(0.5, -353,0.5, -250), 'Out', 'Bounce', 1, true)
- end
- if bool == false then -- Close Shop
- UI.Shop:TweenPosition(UDim2.new(0.5, -353,0, -490), 'Out', 'Bounce', 1, true)
- wait(1)
- UI.Shop.Visible = false
- end
- end
- local function items(bool)
- if bool == true then
- ShopOpened.Value = true
- UI.Items.Visible = true
- UI.Items.Position = UDim2.new(0.5, -350,1, 0)
- UI.Items:TweenPosition(UDim2.new(0.5, -350,0.5, -100), 'Out', 'Bounce', 1, true)
- end
- if bool == false then
- ShopOpened.Value = false
- UI.Items.Position = UDim2.new(0.5, -350,0.5, -100)
- UI.Items:TweenPosition(UDim2.new(0.5, -350,0, -250), 'Out', 'Bounce', 1, true)
- wait(1)
- UI.Items.Visible = false
- end
- end
- local function ClientBuy(item)
- local info = (BuyRemote:InvokeServer(item))
- local alert = UI.Alert:Clone()
- alert.Parent = UI
- alert.Visible = true
- alert.Position = UDim2.new(0.5, -150, 1, 0)
- alert.Title.Text = info[1]
- alert.Message.Text = info[2]
- alert:TweenPosition(UDim2.new(0.5, -150, 0.5, -75), 'Out', 'Bounce', 1)
- end
- UI.Items.GetMore.MouseButton1Click:connect(function()
- items(false)
- shop(true)
- end)
- UI.Shop.Close.MouseButton1Click:connect(function()
- shop(false)
- end)
- UI.UpgradeButton.MouseButton1Click:connect(function()
- if Items
- shop(true)
- end)
- UI.ShopButton.MouseButton1Click:connect(function()
- if ShopOpened.Value == false then
- items(true)
- else
- items(false)
- end
- end)
- UI.Items.Close.MouseButton1Click:connect(function()
- items(false)
- end)
- UI.Items.Item1.Buy.MouseButton1Click:connect(function()
- ClientBuy(UI.Items.Item1.String.Value)
- end)
- UI.Items.Item2.Buy.MouseButton1Click:connect(function()
- ClientBuy(UI.Items.Item2.String.Value)
- end)
- UI.Items.Item3.Buy.MouseButton1Click:connect(function()
- ClientBuy(UI.Items.Item3.String.Value)
- end)
- DevProdFrame.DevProduct1.TextButton.MouseButton1Click:connect(function()
- local id = DevProdFrame.DevProduct1.Id.Value
- MarketplaceService:PromptProductPurchase(player, id)
- end)
- DevProdFrame.DevProduct2.TextButton.MouseButton1Click:connect(function()
- local id = DevProdFrame.DevProduct2.Id.Value
- MarketplaceService:PromptProductPurchase(player, id)
- end)
- DevProdFrame.DevProduct3.TextButton.MouseButton1Click:connect(function()
- local id = DevProdFrame.DevProduct3.Id.Value
- MarketplaceService:PromptProductPurchase(player, id)
- end)
- GamePassFrame.GamePass1.TextButton.MouseButton1Click:connect(function()
- local id = GamePassFrame.GamePass1.Id.Value
- MarketplaceService:PromptGamePassPurchase(player, id)
- end)
- GamePassFrame.GamePass2.TextButton.MouseButton1Click:connect(function()
- local id = GamePassFrame.GamePass2.Id.Value
- MarketplaceService:PromptGamePassPurchase(player, id)
- end)
- GamePassFrame.GamePass3.TextButton.MouseButton1Click:connect(function()
- local id = GamePassFrame.GamePass3.Id.Value
- MarketplaceService:PromptGamePassPurchase(player, id)
- end)
- local function load()
- UI.Enabled = true
- UpdateValues()
- setPlayerInformation()
- LoadShop()
- LoadItems()
- UpdateTotalProfit.OnClientEvent:Connect(UpdateClient)
- end
- load()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement