Unable to cast double to Vector3- what does it mean and how do I fix it?

I want to create a random room generator and I keep getting this error message with a line of code:
error message:
Unable to cast double to Vector3
code:
NewRoom:MoveTo(EndofOldRoom.Position.X, 0.05, EndofOldRoom.Position.Z + 18)

I would love if roblox’s error messages were less vague, but I have to resort to the devforums because “Unable to cast double to Vector3” makes absolutely no sense.

You need to use Vector3.new(x,y,z)

MoveTo() takes a Vector3. you need to do this:

local pos = Vector3.new(EndofOldRoom.Position.X, 0.05, EndofOldRoom.Position.Z + 18)
NewRoom:MoveTo(pos)

Not every function has an overload taking each Vector3 component individually, MoveTo does not.

1 Like

Thanks guys, now it works! I just needed to put Vector3() around it… :skull:

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