Greetings. This is my first post on the Developer forum. In my current game I’m developing, I’m using TopBarPlus by @ForeverHD.
I have made sure that everything is installed correctly in my game, but the code I am using for TopBarPlus isn’t working and is giving me an error which I have provided below. I have also tried using the same code within different games and it works perfectly fine without any errors. This script is located within StarterPlayerScripts
.
Error:
Players.Scripted_Connor.PlayerScripts.LocalScript:17: attempt to index nil with 'align' - Client - LocalScript:17
Code:
repeat wait() until game:IsLoaded()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Icon = require(ReplicatedStorage.TopbarPlus.Icon)
-- Music System Stuff
local MusicMuted = false
local MusicClient = ReplicatedStorage:WaitForChild("MusicSystem").MusicClient
local MusicSound = workspace:WaitForChild("Song")
-- Tree Button Stuff
local TreesEnabled = true
local TreesCaptionText = "Disable Trees"
local TreesButton = Icon.new()
:align("Right")
:setImage(15667131313)
:setLabel(TreesCaptionText,"Viewing")
:oneClick()
TreesButton.selected:Connect(function()
if TreesEnabled == true then
game.Workspace.Trees.Parent = game:GetService("ReplicatedStorage")
TreesEnabled = false
TreesCaptionText = "Enable Trees"
TreesButton:setLabel(TreesCaptionText,"Viewing")
elseif TreesEnabled == false then
game.ReplicatedStorage:WaitForChild("Trees").Parent = game.workspace
TreesEnabled = true
TreesCaptionText = "Disable Trees"
TreesButton:setLabel(TreesCaptionText,"Viewing")
end
end)
-- End of TreesButton
local MusicInfo = Icon.new()
:align("Center")
:lock()
:setImage(6021853047)
:setLabel("SongName")
MusicClient.OnClientEvent:Connect(function(CurrentSong)
MusicInfo:setLabel(CurrentSong)
end)
-- End of MusicInfo
local MusicMuteToggle = Icon.new()
:align("Right")
:setImage(18584997488)
:setLabel("Mute Music","Viewing")
:oneClick()
MusicMuteToggle.selected:Connect(function()
if MusicMuted == false then
MusicSound.Volume = 0
MusicMuted = true
MusicMuteToggle:setLabel("Unmute Music","Viewing")
MusicMuteToggle:setImage(18584997605)
elseif MusicMuted == true then
MusicSound.Volume = 0.5
MusicMuted = false
MusicMuteToggle:setLabel("Mute Music","Viewing")
MusicMuteToggle:setImage(18584997488)
end
end)
-- End of MusicMuteToggle
I’m unsure what to do from this point, but any help would be welcomed.