Typeof() check not working?

Currently, the Datastore’s value is "".
It completely ignores the check and initiates the code.

if typeof(plrcframe) ~= "string" or plrcframe ~= nil then
	print(typeof(plrcframe)) -- prints string, but why does it ignore the previous typeof() check?
	player.Character.PrimaryPart.CFrame = CFrame.new(table.unpack(plrcframe))
end

Because of the second part of the or conditional, if it is a string it can’t be nil which means it will execute the code in the if statement anyways. You might want to use and instead:

if plrcframe ~= nil and typeof(plrcframe) ~= "string" then

Or since you are using table.unpack, you can just check if the value is a table:

if typeof(plrcframe) == "table" then
2 Likes

I KNEW it was a stupid mistake on my end. Thanks a lot!

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