Unable to assign property Position. Vector3 expected, got CFrame

Hello! I am making an attack where a player summons a blue orb above their head and it glides towards their mouse. The problem is, the output says

Unable to assign property Position. Vector3 expected, got CFrame

here’s the code snippet

	spiritbomb.Position = CFrame.lookAt(spiritbomb.CFrame.Position, pos)
 -- pos is mouse.hit.position

you can’t assign Position To CFrame
you should assign the spiritbomb CFrame to CFrame.lookAt(spiritbomb.CFrame.Position, pos)
spiritbomb.CFrame = CFrame.lookAt(spiritbomb.CFrame.Position, pos)

4 Likes

You’re assigning a CFrame value to the position

spiritbomb.CFrame = CFrame.lookAt(spiritbomb.CFrame.Position, pos)
1 Like

no the first argument is supposed to be a Vector3

2 Likes

Yeah I just realized my brain ain’t braining right now

2 Likes

I think the pos variable is a CFrame, can you show us what pos is?

1 Like

It’s stated that it is equivalent to mouse.Hit.Position, besides the error literally states that you’re trying to assign the wrong type of value to a property.

It would say something like Invalid argument #2 Vector3 expected, got CFrame if the pos variable was a CFrame.

1 Like

very unrelated, but does Instance.CFrame.Position actually exist?

is .Position really modifiable like that??? (because i didn’t know :skull:)

1 Like

Yes, CFrame is the combination of the BasePart’s (or Camera/Attachment) position and rotation data

2 Likes

It does, besides the Position property is basically a pointer that points to CFrame.Position

1 Like

Makes sense, but he might have mistaken with Mouse.Target instead of Mouse.Hit, that’s what I was wondering. (edit: nevermind, I’m blind, there is a comment saying what pos is)

1 Like

Well even if they did do that, the error message tells you everything.

1 Like

didn’t know you can just do CFrame.Position, i thought you had to do CFrame.new(x,x,x)

The constructor method is used for cases where you need to set the cframe at a certain position, but if you just want to read what position it’s currently placed at, you can just use CFrame.Position

1 Like

This is problably not the issue but if your orb is a model you would have to use GetPivot(Orb) or PivotTo(location)

This worked, thank you! My brain turned off and completely forgot. Anyways, how would I make the part move towards the mouse? I’m changing the position using Vector3.new() but it doesn’t move towards the mouse instead towards it’s moving only forward.

@ayoub50 wouldn’t that just set the position of the part to the players mouse? I want it to move/glide towards it. (now that I think of it, I probably could’ve used a tween and not use look vectors or anything,.)

1 Like

just assign the Part CFrame to the player mouse’s CFrame

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