How do I make part spawning from attachment correct orientation

I’m making a simple thing where ‘bullets’ constantly spawns from an attachment from player’s head

But for some reason the CFrame of the ‘bullets’ doesn’t update even though I checked in playtest viewing workspace and the attachment WorldCFrame does update

I also tried various method like .Orientation and .Position

I used this head tracking cursor code from This post

This is the basic code inside a script to spawn the ‘bullets’

while wait(1) do
	local Unit = game.ReplicatedStorage.Bullet:Clone()
	Unit.Parent = game.Workspace
	Unit.CFrame = script.Parent:FindFirstChild("Head").HeadFront.WorldCFrame
end
-- HeadFront.WorldCFrame is the visible attachment seen

Anything helps, although I might not respond within days sorry

1 Like

Is the movement of the head and the attachment being replicated to the server?

Also, you didn’t show the script that makes the bullets move. The problem could be that the bullets are not being moved according to their CFrame.

1 Like

Here is the script that makes the bullet move
The bullet is also up holded by ‘BodyForce’ with Force = (0, 0.137, 0)

while wait() do
	script.Parent.Velocity = (script.Parent.CFrame.LookVector) * script.Parent.Speed.Value
end

Here is the attachment WorldCFrame updating although the numbers only update when I click off and on it again and again

Maybe it is replicated to the server? I don’t know

Where’s the script located at?

The bullet spawn script and Head look at cursor local script is in StarterCharacterScripts

If the script is in the “bullet” and you’re using its LookVector, it’s always going to go the same way (assuming the script is in the billet which it probably is because you’re setting its parent’s velocity)

Oh it’s in the head alright lemme compose something real quick for you.

1 Like

Wait why are you using WorldCFrame? It’s equivalent to its parent’s CFrame multiplied by its own. Maybe try changing it to just “CFrame”

1 Like

The CFrame of the attachment is base from the Parent so when using on other things like a part then the CFrame is changed to be from the center of workspace
The WorldCFrame is the CFrame of the attachment from the center of workspace so that’s why I use it

Try this

local Mouse = game.Players.LocalPlayer:GetMouse()

local Head = Character.Head or Character:WaitForChild("Head")
local HeadPosition = Head.Position
local Attachment = Head:WaitForChild("LookAttachment")

local TweenService = game:GetService("TweenService")

local LookCFrame = CFrame.lookat(HeadPosition,Mouse.Hit.Position)

TweenService:Create(Head,TweenInfo.new(.05),{CFrame = LookCFrame}):Play()
1 Like