Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My money gui is not updating with the new values?

Asked by 5 years ago
Edited 5 years ago
-- Values --
local incomecolor = Color3.fromRGB(0,85,0)
local lostcolor = Color3.fromRGB(117,0,0)
local regcolor = Color3.fromRGB(35,35,35)
local currencyframe = script.Parent:WaitForChild("Currency")
local bfirst = false
local wfirst = false

-- Functions --

function transition(base,c2,c1)
    for i = 0,1,0.2 do
        base.ImageColor3 = Color3.new(((c1.r*(1-i))+(c2.r*i)),((c1.g*(1-i))+(c2.g*i)),((c1.b*(1-i))+(c2.b*i)))
        wait()
    end
    base.ImageColor3 = c2
end

local RoundNumber = function(num, numDecimalPlaces)     
    return string.format("%." .. (numDecimalPlaces or 0) .. "f", num)
end

local ShortenNumber = function(num)     
    return math.abs(num) > 999 and RoundNumber(num / 1000, 1) .. "k" or num
end

function CreateNotification(category,color,desc,from,addedto)
    local clone = script.Notification:Clone()
    clone.Category.Text = category
    clone.BarColor.BackgroundColor3 = color
    clone.Desc.Text = desc
    if from ~= nil then
        clone.From.Text = from
    else
        clone.From.Visible = false
    end
    if addedto ~= nil then
        clone.AddedTo.Text = addedto
    else
        clone.AddedTo.Visible = false
    end
    clone.Parent = script.Parent.Notifications
    clone.Animate.Disabled = false
    script.Parent.Notifysound:Play()
end
-- Code --

game.ReplicatedStorage.Remotes.BankAmount.OnClientEvent:Connect(function(value)
    if bfirst == false then
        local shortend = ShortenNumber(value)
        currencyframe.Bank.Amount.Text = shortend
        bfirst = true
    else
        if tonumber(currencyframe.Bank.Amount.Text) > value then
            local base = currencyframe.Bank
            local shortend = ShortenNumber(value)
            currencyframe.Bank.Amount.Text = shortend
            transition(base,lostcolor,base.ImageColor3)
        else
            local base = currencyframe.Bank
            local shortend = ShortenNumber(value)
            currencyframe.Bank.Amount.Text = shortend
            transition(base,incomecolor,base.ImageColor3)
        end
    end
end)

game.ReplicatedStorage.Remotes.WalletAmount.OnClientEvent:Connect(function(value)
    if wfirst == false then
        local shortend = ShortenNumber(value)
        currencyframe.Wallet.Amount.Text = shortend
        wfirst = true
    else
        if tonumber(currencyframe.Wallet.Amount.Text) > value then
            local base = currencyframe.Wallet
            local shortend = ShortenNumber(value)
            currencyframe.Wallet.Amount.Text = shortend
            transition(base,lostcolor,base.ImageColor3)
        else
            local base = currencyframe.Wallet
            local shortend = ShortenNumber(value)
            currencyframe.Wallet.Amount.Text = shortend
            transition(base,incomecolor,base.ImageColor3)
        end
    end
end)

game.ReplicatedStorage.Remotes.Notify.OnClientEvent:Connect(function(category,color,desc,from,addedto)
    CreateNotification(category,color,desc,from,addedto)
end)

This is a local script, it is getting the updated money via a remote.

So when you first join the money does update to what is last saved but it doesn't update when new money is added in the game. I don't know why it isn't working.

0
How are you updating the money? If its manually through studio or through a local script this is an FE issue. DinozCreates 1070 — 5y
0
The money is being updated on the server, it is then sent as a value to the client. Ize_Cubz 18 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

you should use a local script

local Gui = --Your Gui Name
local Text = Gui. --Name Of Text Label/Button

while true do
     Text.Text = game.Players.LocalPlayer.leaderstats.ExampleValue.Value
end
0
It is a local script. Ize_Cubz 18 — 5y
0
hmm then mkhamster 58 — 5y
0
i updated it mkhamster 58 — 5y
Ad

Answer this question