Code Path Problems

For some reason, even when conditions are met, code path at line 12 will not run. If a print statement is inserted between 11 and 12, it is also never called. Leading me to believe, that for some reason, the if statement on line 4 is always run.

function runWarningsCheck()
	for i = 1, 8, 1 do	
		print(warnGuuids[i])
		if game.Workspace.SyncValues.EngineTemps:FindFirstChild("E"..i).Value >= 400 then 
			if warnGuuids[i] == nil then
				warnGuuids[i] = createWarn:Invoke() 
				print(warnGuuids[i])
			else
				continue
			end
		else
			if not warnGuuids[i] == nil then
				print("Clearing warning: ".. warnGuuids[i])
				game.ReplicatedStorage.remoteEvents.clearWarn:Fire(warnGuuids[i])
				warnGuuids[i] = nil
			end	
		end
	end
end

What could be the issue?

2 Likes

Try changing if not warnGuuids[i] == nil then to if warnGuuids[i] ~= nil then
Roblox comparsions aren’t the best so it sometimes doesn’t work.

This is very odd, thank you! I was there for a while thinking my code was flawed.

Should I always use ~= instead of not ==

No problem, there is an article on the developer hub about comparsions so you should check that out.