I want to make a currency indicator with TopBarPlus v3.0, but I have no idea how to change these values inside.
Is there any way to make this? I would appreciate any help provided!
Here’s my “Icon” create script:
I want to make a currency indicator with TopBarPlus v3.0, but I have no idea how to change these values inside.
Is there any way to make this? I would appreciate any help provided!
Here’s my “Icon” create script:
Maybe you can listen to when the value is updated (IntValue?) in leaderstats then connect it to the GetPropertyChanged Signals then do CCicon:setLabel("$".. player.leaderstats.Currency.Value)
Also just to add a note you should make all your Libraries (TopBarPlus) into ReplicatedStorage an example would be… it helps declutter your workspace and organize your game
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local container = ReplicatedStorage.Libs.TopBarPlus
local Icon = require(container.Icon)
Thank you a lot for the help! Here’s how my code looks now:
--assigning TopBar CC indicator thing
local container = game.ReplicatedStorage.TopbarPlus
local Icon = require(container.Icon)
local CCicon = Icon.new()
CCicon:setLabel(player.CC.Value)
CCicon:setImage(95441309712857):setImageScale(1)
CCicon:lock()
CCicon:setRight()
CCicon:setName("CCIndicator")
player.CC:GetPropertyChangedSignal("Value"):Connect(function()
local val = player.CC.Value
CCicon:setLabel(val)
print(val) --debug
end)
Now it works perfectly fine and players can see their wealth!
Looks Cool!
You should replace game.ReplicatedStorage
with game:GetService("ReplicatedStorage")
, when you use GetService its more safe and reliable because you are trying to fetch the service and if any error comes up roblox will handle it for you.
When you use game.ReplicatedStorage
Roblox will not handle any errors and just throw an error at your output. So to keep good practice you can just do game:GetService("ReplicatedStorage")
!
Good luck on your project!
Alright, thank you for noticing!