ViewportSize not working when using > Operator

I recently made a script that checks if a player’s ViewportSize on the X and Y axis is a certain size.
For some reason the greater than operator doesn’t seem to be working while the less than operator does work.
I’m not sure if what is wrong with the script. There are no errors.

local function DeviceType(PlayerDevice)

if PlayerDevice == Touch and game.Workspace.Camera.ViewportSize.X > 800 and game.Workspace.Camera.ViewportSize.X > 401 then -- > Operator doesnt seem to work 
	TextSize = 18.5 -- Confirm The player is on ipad/tablet
	print("Works?")
end

if PlayerDevice == Touch and game.Workspace.Camera.ViewportSize.X < 799 and game.Workspace.Camera.ViewportSize.Y < 399 then -- < Does seem to work
	TextSize = 10.5 -- Confirm player is on a phone
	print("Works?")
end
end
1 Like

You first wrote
game.Workspace.CameraViewportSize.X

and later you did
game.Workspace.Camera.ViewportSize.X

Could that be your problem?

No it was accidental. (30 chars)

Have you printed out your ViewPortSize values before the conditionals to check which conditional is being fulfilled?

Yes


The output prints out 1 even though the actual value is higher than that.