NumberSpinner Module

Can anyone help me implement this module into my script?

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Icon = require(game:GetService("ReplicatedStorage"):WaitForChild("Icon"))

-- Create a new icon for the player's money
local moneyIcon = Icon.new()
	:setLabel("$ 0") -- Initial label for the money icon

-- Function to update the icon's label with the current money
local function updateMoneyDisplay()
	local money = player:GetAttribute("Money") or 0
	moneyIcon:setLabel("$" .. money) -- Update the label with the current money
end

-- Connect to the player's money attribute change event
player:GetAttributeChangedSignal("Money"):Connect(updateMoneyDisplay)

-- Initial update to set the money display correctly when the player joins
updateMoneyDisplay()

Hey dude!
I’ve just figured out how to implement the NumberSpinner into the TopBarPlus module, I’ll link down my module you can use as a reference :smiley:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Modules = ReplicatedStorage.Modules

local Knit = require(Modules.Packages.Knit)
local Icon = require(Modules.Packages.Icon)
local NumberSpinner = require(Modules.Packages.NumberSpinner)

local TopBarController = Knit.CreateController({
	Name = "TopBarController",
	Player = game.Players.LocalPlayer,
	Attributes = {"Currency", "Macaroons" } 
})

function TopBarController:KnitStart()
	for _, Attribute in self.Attributes do
		local Value = self.Player:GetAttribute(Attribute)
		local Prefix = Attribute == "Currency" and "$" or `{Attribute}: `
		local LabelSpinner = NumberSpinner.new()

		local _Icon = Icon.new()
			:setRight()
			:setOrder(4)
			:setSize(100, 32)
			:lock()
			:call(function(icon)
				icon:convertLabelToNumberSpinner(LabelSpinner)
				LabelSpinner.Name = "LabelSpinner"
				LabelSpinner.Prefix = Prefix
				LabelSpinner.Decimals = 0
				LabelSpinner.Duration = 0.25
				LabelSpinner.Value = Value
			end)

		self.Player:GetAttributeChangedSignal(Attribute):Connect(function()
			local NewValue = self.Player:GetAttribute(Attribute)
			LabelSpinner.Value = NewValue
		end)
	end
end

return TopBarController

Have a good day! :wave:

2 Likes