How do i know if the value is UDim2/ UDim?

Hello Developers!
How do i know if the value selected is UDim2/ UDim? I’ve already made a script but it doesn’t really work.

						elseif typeof(SelectionService:Get()[1][gen]) == 'udim2' then -- Not working :(
							if script.Parent.temp:FindFirstChild('Udim2') then
								local cloneset = script.Parent.temp:FindFirstChild('Udim2'):Clone()
								cloneset.Parent = WidgetGui.List
								cloneset.TextLabel.Text = gen
								cloneset.Value.Text = SelectionService:Get()[1][gen]
							end

I’ve tried searching but this is what i found,

Thank you so much for helping me out with the problem!

For this you could use typeof.

local Vector = Vector3.new(0,0,0)
print(typeof(Vector)) -- \\ This would print Vector3.

An example using UDim would be:

local dim2 = UDim2.new()
local dim1 = UDim.new(0,0)
if typeof(dim2) == "UDim2" then
	print(typeof(dim2)) -- \\ Prints UDim2
end

if typeof(dim1) == "UDim" then
	print(typeof(dim1)) -- \\ Prints UDim
end
	
	
1 Like

hello, i have another problem.
How do i know if the value is now a bool? do i have to do it manually as if the statement is == false or == true? here’s a script i constructed:

elseif typeof(SelectionService:Get()[1][gen]) == 'Bool' then

I don’t believe typeof is necessary with booleans since you can just do

if Value == true then
	-- \\ Objects won't make it through since they aren't a boolean.
end

If you send an object or something that doesn’t equal true as the value, it won’t make it through since it isn’t true.

1 Like

Calling typeof() on a bool will return ‘boolean’ not ‘Bool’.

1 Like