If statements not running even though it should

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I am trying to get the player’s shirt and pants templates and save them to a string value so that they can be loaded in when the player wants them.
  2. What is the issue?
    The issue is that the if statements for some reason don’t run.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried to look for solutions but there wasn’t much. There was no error so I couldn’t search up a specific error.
scriptp.Save_see.Save_load.MouseButton1Click:Connect(function()
	 if scriptp.Save_see.Folder:FindFirstChild("pant_"..Save_number).Value == nil then
		print("if statement ran")
		scriptp.Save_see.Folder:FindFirstChild("shirt_"..Save_number).Value = gameW:FindFirstChild(character).Shirt.ShirTemplate
		scriptp.Save_see.Folder:FindFirstChild("pant"..Save_number).Value = gameW:FindFirstChild(character).Pants.PantsTemplate
		scriptp.Save_see.Save_load.Text = "Load Save"
	elseif scriptp.Save_see.Folder:FindFirstChild("pant_"..Save_number).Value == true then
		print("shirt_"..Save_number)
		gameW:FindFirstChild(character).Shirt.ShirtTemplate = scriptp.Save_see.Folder:FindFirstChild("shirt_"..Save_number).Value 
		gameW:FindFirstChild(character).Pants.PantsTemplate = scriptp.Save_see.Folder:FindFirstChild("pant"..Save_number).Value 
		
		
	end
	print("done")
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Your code has two options here, either the object exists or it doesn’t. I would recommend to check for true/false, instead of true/nil, because false and nil will both return false.

You can also use an if/else statement instead because there would only be two options

scriptp.Save_see.Save_load.MouseButton1Click:Connect(function()
	 if not scriptp.Save_see.Folder:FindFirstChild("pant_"..Save_number).Value then
		print("if statement ran")
		scriptp.Save_see.Folder:FindFirstChild("shirt_"..Save_number).Value = gameW:FindFirstChild(character).Shirt.ShirTemplate
		scriptp.Save_see.Folder:FindFirstChild("pant"..Save_number).Value = gameW:FindFirstChild(character).Pants.PantsTemplate
		scriptp.Save_see.Save_load.Text = "Load Save"
	else
		print("shirt_"..Save_number)
		gameW:FindFirstChild(character).Shirt.ShirtTemplate = scriptp.Save_see.Folder:FindFirstChild("shirt_"..Save_number).Value 
		gameW:FindFirstChild(character).Pants.PantsTemplate = scriptp.Save_see.Folder:FindFirstChild("pant"..Save_number).Value 
		
		
	end
	print("done")
end)

If I change the elseif to else then the else sections runs without the if section being true. And for some reason the if not does the same thing the code still skips over the if statement.