Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFrame expected, got Vector3. How do I fix this?

Asked by 5 years ago

trying to move a brick to the mouse position

the local part is specified to a part in workspace

part.CFrame = Mouse.Hit.p

the out put is that it expected cframe and got vector3, how do I fix this?

0
Well, you're giving the CFrame the Vector3 position of the mouse. What exactly were you expecting? I guess you could do part.CFrame = CFrame.new(Mouse.Hit.p). User#25115 0 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Error is pretty self explanatory. You are trying to assign the CFrame property directly to a Vector3 which isn't allowed. You can either just set the CFrame to Mouse.Hit or construct a CFrame our of the position.

Part.CFrame = Mouse.Hit
--// or \\--
Part.CFrame = CFrame.new(Mouse.Hit.Position) --// don't use .p, use .Position
Ad
Log in to vote
0
Answered by 5 years ago

Convert Vector3 to cFrame:

part.CFrame = CFrame.new(Mouse.Hit.p.X, Mouse.Hit.p.Y, Mouse.Hit.p.Z)

I think this would work but I am not sure. I did this before with a Vector3 value from a part's position. Hope this helps!

Answer this question