Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- coroutine.wrap(function()
- -- Fetch the player's GUI and information
- local player = game:GetService("Players").LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local candyTextLabel = playerGui.CrossPlatform.Christmas2024.Container.EventFrames.BattlePass.Info.Tokens.Container.TextLabel
- -- Remotes and Events
- local RoundStartEvent = game:GetService("ReplicatedStorage").Remotes.Gameplay.RoundStart
- -- Variables
- local initialCandyCount = tonumber(candyTextLabel.Text) or 0 -- Initial count of coins when the script starts
- local totalCoins = initialCandyCount -- Tracks current total coins
- local coinGain = 0 -- Tracks coins collected since script execution
- local coinGainLastMatch = 0 -- Tracks coins collected during the last match
- -- Create the GUI
- local screenGui = Instance.new("ScreenGui")
- screenGui.Parent = game:GetService("CoreGui") -- Parent it to CoreGui
- screenGui.IgnoreGuiInset = true -- Ignore the top inset for the GUI
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(0.5, 0, 0.5, 0)
- frame.Position = UDim2.new(0.25, 0, 0.25, 0)
- frame.BackgroundColor3 = Color3.new(0, 0, 0)
- frame.Parent = screenGui
- -- LocalPlayer Username Label
- local usernameLabel = Instance.new("TextLabel")
- usernameLabel.Size = UDim2.new(1, 0, 0.2, 0)
- usernameLabel.Position = UDim2.new(0, 0, 0, 0)
- usernameLabel.Text = "Username: " .. player.Name -- Display the player's username
- usernameLabel.TextScaled = true
- usernameLabel.TextColor3 = Color3.new(1, 1, 1)
- usernameLabel.BackgroundTransparency = 1
- usernameLabel.Parent = frame
- -- Coin Gain Label (Since Script Execution)
- local coinGainLabel = Instance.new("TextLabel")
- coinGainLabel.Size = UDim2.new(1, 0, 0.2, 0)
- coinGainLabel.Position = UDim2.new(0, 0, 0.4, 0)
- coinGainLabel.Text = "❄️ Coin Gain: " .. tostring(coinGain)
- coinGainLabel.TextScaled = true
- coinGainLabel.TextColor3 = Color3.new(1, 1, 1)
- coinGainLabel.BackgroundTransparency = 1
- coinGainLabel.Parent = frame
- -- Coin Gain Last Match Label
- local coinGainLastMatchLabel = Instance.new("TextLabel")
- coinGainLastMatchLabel.Size = UDim2.new(1, 0, 0.2, 0)
- coinGainLastMatchLabel.Position = UDim2.new(0, 0, 0.2, 0)
- coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
- coinGainLastMatchLabel.TextScaled = true
- coinGainLastMatchLabel.TextColor3 = Color3.new(1, 1, 1)
- coinGainLastMatchLabel.BackgroundTransparency = 1
- coinGainLastMatchLabel.Parent = frame
- -- Total Coin Label
- local totalCoinLabel = Instance.new("TextLabel")
- totalCoinLabel.Size = UDim2.new(1, 0, 0.2, 0)
- totalCoinLabel.Position = UDim2.new(0, 0, 0.6, 0)
- totalCoinLabel.Text = "❄️ Total Coin: " .. tostring(totalCoins)
- totalCoinLabel.TextScaled = true
- totalCoinLabel.TextColor3 = Color3.new(1, 1, 1)
- totalCoinLabel.BackgroundTransparency = 1
- totalCoinLabel.Parent = frame
- -- Track and update coins
- local function updateCoins()
- local newTotalCoins = tonumber(candyTextLabel.Text) or 0
- local coinsCollected = newTotalCoins - totalCoins -- Coins collected since last update
- totalCoins = newTotalCoins
- -- Update "Coin Gain" since script execution
- coinGain = totalCoins - initialCandyCount
- coinGainLabel.Text = "❄️ Coin Gain: " .. tostring(coinGain)
- -- Update Total Coin label
- totalCoinLabel.Text = "❄️ Total Coin: " .. tostring(totalCoins)
- -- Update Coin Gain Last Match
- coinGainLastMatch = coinGainLastMatch + coinsCollected
- coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
- end
- -- Reset Coin Gain Last Match when a new match starts
- local function resetCoinGainLastMatch()
- coinGainLastMatch = 0
- coinGainLastMatchLabel.Text = "❄️ Coin Gain Last Match: " .. tostring(coinGainLastMatch)
- end
- -- Connect events
- candyTextLabel:GetPropertyChangedSignal("Text"):Connect(updateCoins)
- RoundStartEvent.OnClientEvent:Connect(resetCoinGainLastMatch)
- end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement