So I am trying to move a model so that it spawns directly in-front, but a little ahead, of the player in-game. But my last few attempts at this have failed. I have used CFrame and MoveTo(), and CFrame works best, though I cannot get it working correctly, as the model doesn't always appear in-front of the player.
How can I move a model directly in-front of a player?
1 answer
I'm not an expert on this but I have been able to accomplish by using the lookvector of the player's humanoidrootpart's CFrame. Here is the code:
local plr = game:GetService("Players"):WaitForChild("vissequ")
while wait(4) do
local model = script:WaitForChild("Model"):Clone()
model:SetPrimaryPartCFrame(plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.LookVector * 12)
model.Parent = game.Workspace
end
This of course assumes the model is a child of the script. As you can see all it does is sets the location of the models primary part equal to the players location + 12 studs in front of that player (using lookvector *12).
This of course will not control the way the model is orientated, but you could do the same type of thing if you desired to control the model's orientation and not just its position.
Somebody else could probably give a better explanation, but I tested that out and it works per your request.
3 comments
For what I am wanting to achieve this is perfect, thank you! Do you know how I would implement the orientation of the model?
Never mind, found your YouTube channel and managed to find a video that showed what I needed. There's some really helpful tutorials on there also, keep it up!
Thank you very much :)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Um be more specific directly in front or something? Also if you are trying to move a model you can't because a model doesn't have a cframe because it doesn't have a position. If you would want to move it you would need to get and script the individual parts with the positions.
Incorrect, you can use Model:MoveTo(), or use Model:SetPrimaryPartCFrame. As stated in my question.