Why isn't "if" working?

For some reason, when I write

if underfoot then
		tween(primaryPart, {CFrame = underfoot.CFrame}, 0.2)
		
		if underfoot == "Exit" then
			if dialogue:PromptYesOrNo("Do you want to go to the next floor?", true) then
				local remotesFolder = replicatedStorage:WaitForChild("Remotes")
				local dungeonLevel = remotesFolder:WaitForChild("DungeonLevel")

				dungeonLevel:Fire(true)
			end
		end
	end

Nothing happens, I tried printing underfoot and it returns "Exit", any ideas why this is happening?

underfoot is Instance, not a string. When you use print, it’s automatically converted to a string so that it can be displayed.

You’d want to either use tostring(underfoot) or underfoot.Name

1 Like

Absolute life-saver! I don’t know how I didn’t see that before, thank you so much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.