Overhead system not working

Hello!

I am working on an overhead gui system, where it shows the player’s name and a special title (rookie, amateur, etc). They unlock different titles at different levels.

The thing that isn’t working is, the title doesn’t change when the player “equips” the title they want.


The way the system works:

When they click on the button, it equips the title, there’s no “Equip” button.


The scripting side:

  • Player clicks on the title, which is a button, which signals a RemoteEvent (RookieEvent) in this case. Script:
local replicatedStorage = game.ReplicatedStorage
local rookieEvent = replicatedStorage.RemoteEvents.TitleEvents.Rookie
local btn = script.Parent

btn.MouseButton1Click:Connect(function()
	rookieEvent:FireServer()
end)
  • The RookieEvent:
local replicatedStorage = game.ReplicatedStorage
local events = replicatedStorage.RemoteEvents.TitleEvents

events.Rookie.OnServerEvent:Connect(function(plr)
	local titleFolder = plr.TitleFolder
	local titleStat = titleFolder.TitleStat.Value
	
	titleStat = (titleStat - titleStat) + 1
	print("Worked")
end)

What should happen:

image_2024-03-04_005752340

What actually happens:

Screenshot 2024-03-03 233143


Each title is binded by a value. So, if the TitleStat value is 0, the title should be “Starter Swinger”, and if it’s set to 1, or changed to 1, it should be “Rookie Swinger”

  • The script which does this:
game.Players.PlayerAdded:Connect(function(plr)
	local titleFolder = plr:WaitForChild("TitleFolder")
	local titleStat = titleFolder:WaitForChild("TitleStat")

	plr.CharacterAdded:Connect(function(char)
		task.wait()
		local OverheadFrame = char.Head:WaitForChild("billboard2").Frame

		local function starter()
			if titleStat.Value == 0 then
				OverheadFrame.TextLabel.Text = "Starter Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
			else
				-- nothing
			end
		end
		
		local function rookie()
			if titleStat.Value == 1 then
				OverheadFrame.TextLabel.Text = "Rookie Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
			else
				-- nothing
			end
		end
		
		local function beginner()
			if titleStat.Value == 2 then
				OverheadFrame.TextLabel.Text = "Beginner Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(0, 255, 225)
			else
				-- nothing
			end
		end
		
		local function amateur()
			if titleStat.Value == 3 then
				OverheadFrame.TextLabel.Text = "Amateur Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(0, 255, 94)
			else
				-- nothing
			end
		end
		
		local function skilled()
			if titleStat.Value == 4 then
				OverheadFrame.TextLabel.Text = "Skilled Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(0, 0, 255)
			else
				-- nothing
			end
		end
		
		local function pro()
			if titleStat.Value == 5 then
				OverheadFrame.TextLabel.Text = "Pro Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(157, 0, 255)
			else
				-- nothing
			end
		end
		
		local function legendary()
			if titleStat.Value == 6 then
				OverheadFrame.TextLabel.Text = "Legendary Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(209, 157, 0)
			else
				-- nothing
			end
		end
		
		local function mythic()
			if titleStat.Value == 7 then
				OverheadFrame.TextLabel.Text = "Mythic Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(212, 255, 0)
			else
				-- nothing
			end
		end
		
		local function godly()
			if titleStat.Value == 8 then
				OverheadFrame.TextLabel.Text = "Godly Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 166)
			else
				-- nothing
			end
		end
		
		local function universal()
			if titleStat.Value == 9 then
				OverheadFrame.TextLabel.Text = "Universal Swinger"
				OverheadFrame.TextLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
				OverheadFrame.TextLabel.TextStrokeColor3 = Color3.fromRGB(255, 255, 255) 
			else
				-- nothing
			end
		end

		starter() -- 1 
		rookie() -- 2
		beginner() -- 3
		amateur() -- 4
		skilled() -- 5
		pro() -- 6
		legendary() -- 7
		mythic() -- 8
		godly() -- 9
		universal() -- 10

		titleStat.Changed:Connect(function()
			starter()
			rookie()
			beginner()
			amateur()
			skilled()
			pro()
			legendary()
			mythic()
			godly()
			universal()
		end)
	end)
end)

The issue:

When I click the “Rookie Swinger” button, it doesn’t change the title, and even if I change the TitleStat value manually, it still doesn’t change.

Sorry for the long post, any help is appreciated. Thanks!

The issue here is that you are not checking if the .Value is changed, so you would want to use :GetPropertyChangedSignal(“Value”) instead of .Changed.

Edit: that is not the issue the issue is you are saying titleStat is equal to the Value, which means it is just a number and not the actual object. What you need to do is this:

local titleStat = titleFolder.TitleStat
titleStat.Value = 1