Putting a model infront of a player

Hi all,

I’m working on a placement system for spike strips. I found the Y position via Raycasting, but the placement preview doesn’t seem to rotate with the player.

Code:

local Y_Pos = RaycastResult.Position.Y
local NewCF = RootPart.CFrame + RootPart.CFrame.LookVector * 5
CurrentPreviewModel:PivotTo(CFrame.new(NewCF.X, Y_Pos, NewCF.Z))

Why is the primary part of the preview model not keeping the same orientation as the player’s HumanoidRootPart?

Thanks in advance.

You’re only setting the position. NewCF.X is just the X position. (If I remember correctly)

Yeah I know, I was wondering how I could implement CFrame.lookAt in this context

So I would do: CFrame.new(Vector3.New(NewCF.X, Y_Pos, NewCF.Z) + RootPart.Cfrmame.LookVector * 5)

(Idk if that’ll work tho idk)

Unfortunately that made no difference :sob:

SO I suck at typing… I meant this: : PivotTo(CFrame.new(Vector3.New(NewCF.X, Y_Pos, NewCF.Z)) + RootPart.Cfrmame.LookVector * 5)

Is that not exactly the same thing you wrote before?

This was the solution:

local Y_Pos = RaycastResult.Position.Y
local NewCF = RootPart.CFrame * CFrame.new(0, 0, -5)
CurrentPreviewModel:PivotTo(CFrame.new(NewCF.X, Y_Pos, NewCF.Z) * CFrame.fromOrientation(NewCF:ToOrientation()))
1 Like

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