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

can this error be explained?

So, i have been working on a falling script that when falling between two distances, and planning on having it kill the person on impact if they don't activate the parachute between the distances. The error is "attempt to compare two userdata values"

plr = game.Players.LocalPlayer
local warn = false
plr.Character.Torso.Changed:connect(function()
print("Torso Prop has changed!")
print(plr.Character.Torso.Position)
6.)	if plr.Character.Torso.Position > Vector3.FromAxis(Enum.Axis.Y, 134) and plr.Character.Torso.Position < Vector3.FromAxis(Enum.Axis.Y, 1180)and plr.Backpack.Parachute ~= nil then
print("Falling")
warn = true
while warn == true do
plr.PlayerGui.Fallwarn.warning.Visible = true
wait(2)
plr.PlayerGui.Fallwarn.warning.Visible = false
wait(2)
end
else
warn = false
plr.PlayerGui.Fallwarn.warning.Visible = false
end
end)

any help with this? (The error is at line 6.)

1 answer

You can't compare a whole vector with an axis. The vector I am talking about is when comparing the position.

As an vector is built up by using three different axis'es, X axis, Y axis and Z axis.

This makes the vector3 act like a table containing 3 arrays.

Which makes it impossible to compare this 'table' with another array.

Example:

table = {
one    = "1",
two    = "2",
three = "3,"
}

if table > 2 then
-execute stuff
end

That would also give us the error: 'Attempt to compare two userdata values'

1 comment

0

okay, that explains it. Now, can you tell me a way to fix this?

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