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

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

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?

1 comment

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).

2 answers

✓ Accepted answer

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

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!

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