Hello, my name is nachsor(aka skelyvelocirap). I am in the progress of making a game on Roblox, it is fairly close to being playable but I did encounter a problem :|. I am trying to move a model to the position my mouse is at but I need to use CFrame. There is this MoveTo() Function which I have an issue with. When I try feeding it a Frame value:
mtarget:MoveTo(CFrame.new(posX, 0, posZ))
it just shows me an error: 14:17:23.212 - Unable to cast CoordinateFrame to Vector3
This error is fairly annoying as I really want to use CFrame for it as my game is a sandbox Tycoon (not the name) and I want the placement system to place the models at a specific hight but go through blocks if needed.
Is there a way to use Frame instead of the Vector3?
thank you -nachsor
Why don't you use SetPrimaryPartCFrame? Just make sure that the model has a hitbox and that the models primary part is the hitbox.
I am pritty sure that this: 'add, subtract or multiply the value, not set the value to a specific amount.' is false. As the function it self is named: SETprimarypartcframe.
Anyways, to awnser your question. No it is not possible, you need to use SetPrimaryPartCFrame or loop over every part in the model. Here is how you can do it with SetPrimaryPartCFrame:
--For this to work there needs to be a part in the model named hitbox and that is set as primary part. mtarget:SetPrimaryPartCFrame(CFrame.new(posX, 0, posZ))
The problem with MoveTo() is that it positions the model, what that means is that if there is another part in the way, it will move above that part instaid of ignoring that part. With models that have bricks outside of thier hitbox this can be an issue. -And you aren't able to rotate the model, which also can be a problem. If you need to use MoveTo() you can use this:
mtarget:MoveTo(Vector3.new(posX, 0, posZ)) --or use \/ but /\ is more efficient. mtarget:MoveTo(CFrame.new(posX, 0, posZ).p)