Moving part to the player's location

Hello, I am trying to make a system that moves a part to a player’s location. So far I have the character model of the player and am able to locate the player’s location.

I just can’t figure out how to do the actual setting of the part’s position.

One thing I have tried is:
script.Parent.Position.Cframe = character.PrimaryPart.Position.Cframe

That doesn’t work but its just an idea of what I am trying to do.

Thank you for your help.

3 Likes

You can’t do PrimaryPart.Position.CFrame. The position and CFrame are 2 different properties. Try this.

script.Parent.CFrame = character.PrimaryPart.CFrame
8 Likes

Cframe should be CFrame and CFrame isn’t a property of Position, it’s the other way around.

4 Likes

Cframe should be CFrame and you can’t do Position.CFrame you will get an error instead do PrimaryPart.CFrame

3 Likes

script.Parent.CFrame = character.HumanoidRootPart.CFrame
or change humanoidrootpart to the part that is in the centre of the character
if there is no part in the centre, add a part in the centre

3 Likes

The part will go to the root part of the humanoid. This probably isn’t very useful. If you want it to go into their hand. You can make the part a tool and it will automatically go into the players hand. I hope this helps

2 Likes

I know that I’m pretty late but I just wanted to point out your error.
This error being that you said

script.Parent.Position.CFrame = character.PrimaryPart.Position.CFrame

CFrame and Position two completely different properties of parts. So, saying Position.CFrame would result in an error. CFrame is not a property of Position, CFrame is simply the rotation and position of a part. You should either stick to CFrame or Position, though I would recommend CFrame. As for it also maintains the rotation of the part, rather than just putting the part at a set position.

Try Putting this instead:

script.Parent.CFrame = character.PrimaryPart.CFrame

You could also just use the HumanoidRootPart like @DybalaplaysYT said, but then again the PrimaryPart of the character is the HumanoidRootPart .

Also, keep in mind the HumanoidRootPart is in the center of the character. So if that’s where you don’t intend the part to go to then I would recommend setting to a specific Body Part of character.

2 Likes