Advertisement
suramraja1

p3s9nin

Apr 15th, 2024 (edited)
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.02 KB | None | 0 0
  1. coroutine.wrap(function()
  2.     local screenGui = Instance.new("ScreenGui")
  3.     screenGui.Name = "FullScreenGUI"
  4.     screenGui.ResetOnSpawn = false
  5.     screenGui.IgnoreGuiInset = true -- Ensures it covers the entire screen, including the top area
  6.  
  7.     -- Add to CoreGui
  8.     screenGui.Parent = game:GetService("CoreGui")
  9.  
  10.     -- Create a Frame to hold the text
  11.     local frame = Instance.new("Frame")
  12.     frame.Size = UDim2.new(1, 0, 1, 0) -- Fullscreen
  13.     frame.Position = UDim2.new(0, 0, 0, 0)
  14.     frame.BackgroundColor3 = Color3.new(0, 0, 0) -- Black background
  15.     frame.BorderSizePixel = 0
  16.     frame.Parent = screenGui
  17.  
  18.     -- Create a UIListLayout for text alignment
  19.     local layout = Instance.new("UIListLayout")
  20.     layout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  21.     layout.VerticalAlignment = Enum.VerticalAlignment.Center
  22.     layout.SortOrder = Enum.SortOrder.LayoutOrder
  23.     layout.Parent = frame
  24.  
  25.     -- Create a function to add text elements
  26.     local function createTextElement(parent, text)
  27.         local textLabel = Instance.new("TextLabel")
  28.         textLabel.Text = text
  29.         textLabel.Font = Enum.Font.GothamBold
  30.         textLabel.TextColor3 = Color3.new(1, 1, 1) -- White text
  31.         textLabel.TextScaled = true
  32.         textLabel.Size = UDim2.new(1, 0, 0.1, 0) -- Adjust size for each label
  33.         textLabel.BackgroundTransparency = 1
  34.         textLabel.Parent = parent
  35.         return textLabel
  36.     end
  37.  
  38.     -- Add text elements to the frame
  39.     local playerName = game.Players.LocalPlayer.Name
  40.     createTextElement(frame, "Username: " .. playerName) -- Display the player's username
  41.  
  42.     local coinGainLastMatchLabel = createTextElement(frame, "❄️ Coin Gain Last Match: 0") -- Initialize as 0
  43.     local coinGainLabel = createTextElement(frame, "❄️ Coin Gain: 0") -- Initialize as 0
  44.     local totalCoinLabel = createTextElement(frame, "❄️ Total Coin: Loading...") -- Placeholder text
  45.  
  46.     -- Path to the candyText
  47.     local candyTextLabel = game:GetService("Players").LocalPlayer.PlayerGui.CrossPlatform.Christmas2024.Container.EventFrames.BattlePass.Info.Tokens.Container.TextLabel
  48.  
  49.     -- Store the initial CandyText value
  50.     local initialCandyText = tonumber(candyTextLabel.Text) or 0
  51.     local coinGainLastMatch = 0 -- Track coins collected during the last match
  52.  
  53.     -- Function to update Coin Gain and Total Coin
  54.     local function updateCoinData()
  55.         local currentCandyText = tonumber(candyTextLabel.Text) or 0 -- Safely convert to number
  56.         local coinGain = currentCandyText - initialCandyText -- Calculate coins gained since script started
  57.         coinGainLabel.Text = "❄️ Coin Gain: " .. tostring(coinGain) -- Update Coin Gain
  58.         totalCoinLabel.Text = "❄️ Total Coin: " .. tostring(currentCandyText) -- Update Total Coin
  59.     end
  60.  
  61.     -- Reset Coin Gain Last Match when a new match starts
  62.     local function resetCoinGainLastMatch()
  63.         coinGainLastMatch = 0
  64.         coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
  65.     end
  66.  
  67.     -- Add coins to Coin Gain Last Match
  68.     local function addCoinToLastMatch(cointype, current, max)
  69.         if cointype == "SnowToken" then
  70.             coinGainLastMatch = coinGainLastMatch + 1 -- Increment coin count
  71.             coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
  72.         end
  73.     end
  74.  
  75.     -- Connect the TextChanged event to dynamically update Coin Gain and Total Coin
  76.     candyTextLabel:GetPropertyChangedSignal("Text"):Connect(updateCoinData)
  77.  
  78.     -- Initial update
  79.     updateCoinData()
  80.  
  81.     -- Connect to CoinCollectedEvent to track Coin Gain Last Match
  82.     local CoinCollectedEvent = game.ReplicatedStorage.Remotes.Gameplay.CoinCollected
  83.     CoinCollectedEvent.OnClientEvent:Connect(addCoinToLastMatch)
  84.  
  85.     -- Reset Coin Gain Last Match when a new match starts
  86.     local RoundStartEvent = game.ReplicatedStorage.Remotes.Gameplay.RoundStart
  87.     RoundStartEvent.OnClientEvent:Connect(resetCoinGainLastMatch)
  88. end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement