Help with Topbarplus2

[Code by @ForeverHD ]

i am trying to make a Icon that changes when my value changes. [In this case used for music]

My issue is it is not changing/working.

Code
local Player = game:GetService("Players").LocalPlayer

local GroupId = 11587846

local rank = Player:GetRoleInGroup(GroupId)

local rankid = Player:GetRankInGroup(GroupId)

local player = game:GetService("Players").LocalPlayer

local playerGui = player.PlayerGui

local gui = playerGui:WaitForChild("settings")

local settings1 = gui.settings

local credits = playerGui:WaitForChild("credits").credits

local Icon = require(game:GetService("ReplicatedStorage").Icon)

local musicsong = workspace.currentsong.Value

local musicsong2 = workspace.currentsong

Icon.new()
:setName("Current-Song")
:setImage(7203694787)
:setMid()
:lock()
:setSize(100,32)
:bindEvent("deselected", musicsong:Changed:Connect(function(value)
	Icon:setLabel(musicsong, "hovering")
	Icon:setLabel(musicsong, "deselected")
	Icon:setLabel(musicsong, "selected")
end))

Errors:

Please help me if you can!
-Kieranl29

1 Like

You must clarify what problem you have.
For example, ‘No error messages’, ‘Theres error message: …’
This makes more developers want to reply.


This is my error. However there is a funcation…

What line is the error from even? You cut it off which makes it a lot harder to figure out where it’s coming from.

IT IS the only error there. [red text]

You cut off the blue text which shows which line the error is from

Ok boi here is a better version

Doesn’t seem like there’s 60 lines in the code you provided. Are you sure the code you showed is from PlayerScripts.LocalScript?

HERE IS MY UPDATED CODE:

local Player = game:GetService("Players").LocalPlayer
local GroupId = 11587846
local rank = Player:GetRoleInGroup(GroupId)
local rankid = Player:GetRankInGroup(GroupId)

local player = game:GetService("Players").LocalPlayer
local playerGui = player.PlayerGui 
local gui = playerGui:WaitForChild("settings")
local settings1 = gui.settings
local credits = playerGui:WaitForChild("credits").credits
local Icon = require(game:GetService("ReplicatedStorage").Icon)

local musicsong = workspace.currentsong.Value
local musicsong2 = workspace.currentsong

if rankid == 0 then
	rank = "✅| Visitor"
end

Icon.new()
:setName("rank")
:setRight()
:lock()
:setSize(100, 32)
:setImage(7199868835)	
:setLabel(rank, "deselected")
:setLabel(rank, "selected")
:setLabel("RankID: " .. rankid, "hovering")


Icon.new()
:setName("Settings")
:setImage(7202333684)
:setCaption("Settings(g)")
:bindToggleKey(Enum.KeyCode.G)
:bindEvent("selected", function()
	settings1.Visible = true
end)
:bindEvent("deselected", function()
	settings1.Visible = false
end)


Icon.new()
:setName("Credits")
:setImage(7199802249)
:notify()
:setRight()
:setCaption("Credits(c)")
:bindToggleKey(Enum.KeyCode.C)
:bindEvent("selected", function()
	credits.Visible = true
end)
:bindEvent("deselected", function()
	credits.Visible = false
end)



Icon.new()
:setName("Current-Song")
:setImage(7203694787)
:setMid()
:lock()
:setSize(100,32)
:bindEvent("deselected", musicsong:Changed:Connect(function(value)
	Icon:setLabel(musicsong, "hovering")
	Icon:setLabel(musicsong, "deselected")
	Icon:setLabel(musicsong, "selected")
end))
:bindEvent("deselected", musicsong:Changed:Connect(function(value)
	Icon:setLabel(musicsong, "hovering")
	Icon:setLabel(musicsong, "deselected")
	Icon:setLabel(musicsong, "selected")
end))

What are you doing here…? I have no idea, and I guess this is problem

I have a string value in the workspace, and when it changes I want the label to update…
That is how i was told you can do it.

I don’t think this is correct.

musicsong:Changed:Connect(function(value)
	Icon:setLabel(musicsong, "hovering")
	Icon:setLabel(musicsong, "deselected")
	Icon:setLabel(musicsong, "selected")
end)

This code is wrong too. I don’t know what you want to do.
I recommend you learning lua.

Ok tell @ForeverHD that basted of he told me to use this… Bro just be useful next time you talk to me your clearly lieing.

I’m not lying (That will be illegal in devforum), Because I really don’t know what you want to do with this code.
Why you are calling setLabel in 3 times continus, And binding event to connect function, witch returns nil.

1 Like

I think what part of what @dollychun is trying to say is that you are changing the icon 3 times without any wait, so that the end result is it almost instantly going to selected.

i dont care, I just need it to stop erroring on the top line of that icon…

Also, binding event to nil that connect returns.

1 Like

Because they wont know about it unless they use the script modules…

You must care to fix errors! thats not how script works

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)