Look vector not working?

I was trying to find it on the roblox definition page(I forgot what it’s called) and looking for tutorials.
So I was making an inventory system that can drop items. So when you click on it drops the item right in from of your head, but look vector doesn’t work. Here’s the error part of my script:

Cloned:SetPrimaryPartCFrame(CFrame.new(TheHeadOfThePlayersCharacter.CFrame.lookVector * 4))

here’s the error:

22:27:44.321 - CFrame is not a valid member of Vector3

any help is appreciated

3 Likes

Then, how would I be able to make it a c frame?

I tried that before I posted this(sorry, forgot to mention it), and it says that you cannot use vector 3 in c frame

What is TheHeadOfThePlayersCharacter? is it a vector3 value or an object? (also ignore my previous code, i forgot that doing what i did doesn’t work )

A vector3 value, it says in the error on the post.

TheHeadOfThePlayersCharacter seems to be a Vector3 object, not an Instance. Make sure it’s actually the head and not head.Position.

The error is thrown because you’re essentially trying to call Vector3.CFrame, which doesn’t exist.

2 Likes

You you should be referencing an object, not a vector position

no, but if I directly reference the object, then it will clone on top of the players head

I did 30chars…

1 Like

That might be due to physics, if the object isn’t anchored and is collidable then it’ll push the two objects apart. Either anchor the clone or make it uncollidable.

But, I want it so that it clones in front of the character

What you want to do is the get the CFrame Position of the Head, not the vector position

I am getting the CFrame with .CFrame though, but it still has a vector issue. And I’m not referencing .Position or anything:

game.Players.LocalPlayer.Character:WaitForChild("Head")

Try this:
Cloned:SetPrimaryPartCFrame(TheHeadOfThePlayersCharacter.CFrame * CFrame.new(0, 0, 4))

You didn’t add the position, it’d just spawn at the LookVector which is a unit vector. (0-1)
The way I put it above will set it to the head’s position and rotation + offset of 4 on Z-Axis (Z being depth, so forward due to the rotation being included, if that doesn’t work try setting it to 4, 0, 0 or the negative variations of them.)

Although you might want to use the HumanoidRootPart instead to position the clone. (Unless it’s a specific case I guess.)

2 Likes

@Dysche’s Solution should work and This might Help in the future(or whenever):

(Sorry for all the dumb replies i made, im tired lol)

1 Like

It doesn’t work, I tried using the humanoidrootpart but it brings up the same error as before:L
08:18:02.195 - CFrame is not a valid member of Vector3

@Jaycbee05 @DragRacer31 @Dysche
For more info that I think I didn’t need at that time:
The part i am cloning is a model from the replicated storage, and I’m setting the parent to workspace. All this is done on a server script when a remote event is fired. In the local script I put in all the things like finding the character and what to clone.

What type is the object you’re trying to reference? It says you’re trying to call .CFrame on a Vector3, can you post more code maybe?

I’m referencing the players head/humanoid root part from a local script, then using a remote event to transfer that information to a server script.

Using the player who fired parameter, try doing:

Cloned:SetPrimaryPartCFrame(CFrame.new(player.Character.Head.CFrame.lookVector * 4))
1 Like