Hello, I am having trouble trying to get an if statement to run.
Here is the code, placed in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
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
changeClassicHeadgear(player.Character)
print("if statement is working")
elseif headgearSelected == "Agent" then
changeAgentHeadgear(player.Character)
print("if statement is working")
elseif headgearSelected == "Diver" then
changeDiverHeadgear(player.Character)
print("if statement is working")
end
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.