Advertisement
suramraja1

rehasunset

Apr 14th, 2024 (edited)
3,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.19 KB | None | 0 0
  1. coroutine.wrap(function()
  2.     -- Fetch the player's GUI and information
  3.     local player = game:GetService("Players").LocalPlayer
  4.     local playerGui = player:WaitForChild("PlayerGui")
  5.     local candyTextLabel = playerGui.CrossPlatform.Christmas2024.Container.EventFrames.BattlePass.Info.Tokens.Container.TextLabel
  6.  
  7.     -- Remotes and Events
  8.     local RoundStartEvent = game:GetService("ReplicatedStorage").Remotes.Gameplay.RoundStart
  9.  
  10.     -- Variables
  11.     local initialCandyCount = tonumber(candyTextLabel.Text) or 0 -- Initial count of coins when the script starts
  12.     local totalCoins = initialCandyCount -- Tracks current total coins
  13.     local coinGain = 0 -- Tracks coins collected since script execution
  14.     local coinGainLastMatch = 0 -- Tracks coins collected during the last match
  15.  
  16.     -- Create the GUI
  17.     local screenGui = Instance.new("ScreenGui")
  18.     screenGui.Parent = game:GetService("CoreGui") -- Parent it to CoreGui
  19.     screenGui.IgnoreGuiInset = true -- Ignore the top inset for the GUI
  20.  
  21.     local frame = Instance.new("Frame")
  22.     frame.Size = UDim2.new(0.5, 0, 0.5, 0)
  23.     frame.Position = UDim2.new(0.25, 0, 0.25, 0)
  24.     frame.BackgroundColor3 = Color3.new(0, 0, 0)
  25.     frame.Parent = screenGui
  26.  
  27.     -- LocalPlayer Username Label
  28.     local usernameLabel = Instance.new("TextLabel")
  29.     usernameLabel.Size = UDim2.new(1, 0, 0.2, 0)
  30.     usernameLabel.Position = UDim2.new(0, 0, 0, 0)
  31.     usernameLabel.Text = "Username: " .. player.Name -- Display the player's username
  32.     usernameLabel.TextScaled = true
  33.     usernameLabel.TextColor3 = Color3.new(1, 1, 1)
  34.     usernameLabel.BackgroundTransparency = 1
  35.     usernameLabel.Parent = frame
  36.  
  37.     -- Coin Gain Label (Since Script Execution)
  38.     local coinGainLabel = Instance.new("TextLabel")
  39.     coinGainLabel.Size = UDim2.new(1, 0, 0.2, 0)
  40.     coinGainLabel.Position = UDim2.new(0, 0, 0.4, 0)
  41.     coinGainLabel.Text = "❄️ Coin Gain: " .. tostring(coinGain)
  42.     coinGainLabel.TextScaled = true
  43.     coinGainLabel.TextColor3 = Color3.new(1, 1, 1)
  44.     coinGainLabel.BackgroundTransparency = 1
  45.     coinGainLabel.Parent = frame
  46.  
  47.     -- Coin Gain Last Match Label
  48.     local coinGainLastMatchLabel = Instance.new("TextLabel")
  49.     coinGainLastMatchLabel.Size = UDim2.new(1, 0, 0.2, 0)
  50.     coinGainLastMatchLabel.Position = UDim2.new(0, 0, 0.2, 0)
  51.     coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
  52.     coinGainLastMatchLabel.TextScaled = true
  53.     coinGainLastMatchLabel.TextColor3 = Color3.new(1, 1, 1)
  54.     coinGainLastMatchLabel.BackgroundTransparency = 1
  55.     coinGainLastMatchLabel.Parent = frame
  56.  
  57.     -- Total Coin Label
  58.     local totalCoinLabel = Instance.new("TextLabel")
  59.     totalCoinLabel.Size = UDim2.new(1, 0, 0.2, 0)
  60.     totalCoinLabel.Position = UDim2.new(0, 0, 0.6, 0)
  61.     totalCoinLabel.Text = "❄️ Total Coin: " .. tostring(totalCoins)
  62.     totalCoinLabel.TextScaled = true
  63.     totalCoinLabel.TextColor3 = Color3.new(1, 1, 1)
  64.     totalCoinLabel.BackgroundTransparency = 1
  65.     totalCoinLabel.Parent = frame
  66.  
  67.     -- Track and update coins
  68.     local function updateCoins()
  69.         local newTotalCoins = tonumber(candyTextLabel.Text) or 0
  70.         local coinsCollected = newTotalCoins - totalCoins -- Coins collected since last update
  71.         totalCoins = newTotalCoins
  72.  
  73.         -- Update "Coin Gain" since script execution
  74.         coinGain = totalCoins - initialCandyCount
  75.         coinGainLabel.Text = "❄️ Coin Gain: " .. tostring(coinGain)
  76.  
  77.         -- Update Total Coin label
  78.         totalCoinLabel.Text = "❄️ Total Coin: " .. tostring(totalCoins)
  79.  
  80.         -- Update Coin Gain Last Match
  81.         coinGainLastMatch = coinGainLastMatch + coinsCollected
  82.         coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
  83.     end
  84.  
  85.     -- Reset Coin Gain Last Match when a new match starts
  86.     local function resetCoinGainLastMatch()
  87.         coinGainLastMatch = 0
  88.         coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
  89.     end
  90.  
  91.     -- Connect events
  92.     candyTextLabel:GetPropertyChangedSignal("Text"):Connect(updateCoins)
  93.     RoundStartEvent.OnClientEvent:Connect(resetCoinGainLastMatch)
  94. end)()
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement