If statement is not running

Hello, I am having trouble trying to get an if statement to run.

Here is the code, placed in ServerScriptService:

repeat wait() until player.SelectedItems
local selectedItems = player.SelectedItems

repeat wait() until selectedItems.HeadgearSelected
local headgearSelected = selectedItems.HeadgearSelected

print("Event is running")

if headgearSelected == "Classic" then
	print("if statement is working")
elseif headgearSelected == "Agent" then
	print("if statement is working")
elseif headgearSelected == "Diver" then
	print("if statement is working")

The headgearSelected value is a String Value inside the selectedItems folder, which is inside the player.The functions being called are functions that change the look of the player.

My issue is that the if statement is not running, there is no output, none of the functions are being fired, the only output shown is the print statement showing that the event has fired.

I have no idea if this is my own mistake or a bug on Roblox’s side. I would appreciate if someone could help me find a fix to this, thanks.

You are only referencing the instance, not its value. So add a .Value.

1 Like

Thank you, that was a bad mistake of mine