Trying to get model to spawn in front of player and look the direction of the player

This is how im getting it to spawn in front of the player

local pos = (plr.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-5)).p
	
flamethrower:MoveTo(pos+Vector3.new(0,5,0))

I just dont know how to make it face the same direction as the player, ive tried a lot and i just cant figure it out

You can use PVInstance:PivotTo to specify a CFrame (rotation and position) of an object that is eligable to be Pivoted, and we set the rotation to be equivalent to the Player’s making it look in the same direction (away)

local pos = (plr.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-5)).p
	
flamethrower:PivotTo(CFrame.new(pos+Vector3.new(0,5,0)) * plr.Character.Rotation)

it says that Rotation is not a valid member or plr.Character

Sorry that was a typo I meant to say plr.Character.HumanoidRootPart.Rotation

local pos = (plr.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-5)).p
	
flamethrower:PivotTo(CFrame.new(pos+Vector3.new(0,5,0)) * plr.Character.HumanoidRootPart.Rotation)

now it says unable to cast vector3 to coordinateframe

Sorry I keep making typo’s :sob:, its supposed to be plr.Character.HumanoidRootPart.CFrame.Rotation

local pos = (plr.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-5)).p
	
flamethrower:PivotTo(CFrame.new(pos+Vector3.new(0,5,0)) * plr.Character.HumanoidRootPart.CFrame.Rotation)

its off by 90 degrees, do you know how I would go about changing the rotation

You would offset it by multiplying plr.Character.HumanoidRooPart.CFrame.Rotation by CFrame.Angles(0, math.rad(90), 0). If it rotates it on the wrong axes move math.rad(90) to one of the other paramters to rotate it on a different axes.

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