This CFraming problem has been causing me problems no matter what variations I try. I basically just want an item to spawn directly in front of a player on the ground. I’m using a raycast to find the ground’s position. The item will spawn on the ground around the player, but not in the rotation that makes the front face the player, and also the position is not in front of the player. The position is relative to the XYZ axis of the world, and not the player’s rotation. Any help would be appreciated!
local caster2 = player.Character.UpperTorso
local rayOrigin2 = caster2.Position
local distanceLength2 = 5.75
local rayDirection2 = caster2.Position + Vector3.new(0,-100,0) --Vector3.new(caster.CFrame.lookVector.X * distanceLength2, -3.1, caster.CFrame.lookVector.Z * distanceLength2)
local raycastParams2 = RaycastParams.new()
raycastParams2.FilterDescendantsInstances = {caster2.Parent, box}
raycastParams2.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult2 = workspace:Raycast(rayOrigin2, rayDirection2, raycastParams2)
LOOK = Vector3.new(player.Character.HumanoidRootPart.CFrame.X, raycastResult2.Position.Y+(item.Size.Y/2), player.Character.HumanoidRootPart.CFrame.Z)
cframe2 = CFrame.new(raycastResult2.Position) * CFrame.new(Vector3.new(CFrame.new(raycastResult2.Position):ToObjectSpace(CFrame.new(0,(item.Size.Y/2), 0)), LOOK))