Fps Counter For TopBarPlus

Hey, Im Using Hd admins Top Bar Plus, Which is used to make icons in the top bar.
Its Very Usefull as it allows the main screen of the player not to get filled up by other guis.
Now with that being said, Let me get into my problem.
Im trying to have an Fps Counter on one of the buttons, and im having a hard time doing so.
There is one really accurate and good fps script

local Heartbeat = game:GetService("RunService").Heartbeat
local LastIteration, Start
local FrameUpdateTable = { }
local function HeartbeatUpdate()
LastIteration = tick()
for Index = #FrameUpdateTable, 1, -1 do
FrameUpdateTable[Index + 1] = (FrameUpdateTable[Index] >= LastIteration - 1) and FrameUpdateTable[Index] or nil
FrameUpdateTable[1] = LastIteration
local CurrentFPS = (tick() - Start >= 1 and #FrameUpdateTable) or (#FrameUpdateTable / (tick() - Start))
CurrentFPS = math.floor(CurrentFPS )
FpsLabel.Text = "" .. CurrentFPS .. " FPS"
Start = tick()
Anyway if you dont know already topbarplus has funtions made by ForeverDev, So the functions like :setlabel or something can be used.
However im not really sure how to go about this, any help will be appreciated thanks.

Can you format your code by selecting it all and click this button in the editor Screenshot by Lightshot please.


Select your code and click the button inside the red square.


Now in regards to your post, you could have the button toggle a GUI in for example the bottom left corner that shows the players FPS. Constantly setting a label in Topbar+ is not an option from experience using it.

Hey, I know a way, actually I am late to this topic a LOT but if anyone wonders how to do the same, here is how you can do it:

first make a value inside player that changes with the fps of player.
then use TopBarPlus, insert it and keep it inside of replicated storage, go to starterplayerscripts and make a script in it, then.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Icon = require(ReplicatedStorage.Icon)
local icon = Icon.new()

local plr = game.Players.LocalPlayer
local FPS = plr:WaitForChild("FPS")

icon:setLabel(FPS.Value .. " FPS")
icon:setCornerRadius(0, 8)
icon:setProperty("deselectWhenOtherIconSelected", true)
icon:setLeft() -- type icon:setRight() if you want it at right
icon:lock() -- basically make the label not selectable

	if FPS then
		icon:setLabel(FPS.Value .. " FPS")