Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I fix the "attempt to compare two userdata values" error?

I keep getting the error "attempt to compare two userdata values" with this part of my script:

for _,v in pairs(children) do
	if v.Position >= game.Workspace.dud.Position then
		v:Destroy()
	end
end

As soon as I change == to >= it comes up with that error. Please explain why and tell me how to fix it.

2 comments

0

What are you trying to compare?

0

Obviously v.Position and game.Workspace.dud.Position

1 answer

The problem here is that you cannot ask the program to check if a vector is bigger than the other, or a vector is smaller than the other.

Though a way to fix it would be to refer to each axis on its own.

So it would look something like this:

for _,v in pairs(children) do
    if v.Position.Y >= game.Workspace.dud.Position.Y then -- assuming you want to compare the y-axis
        v:Destroy()
    end
end

Hope it helped!

2 comments

0

Thank you.

0

how do u do that with udim2

This discussion is preserved as it was. New answers, comments, and votes are closed.