Problems with attachment following mouse (goes left and right, but not up and down)

I’ve been making a flamethrower script, but the problem is that the attachment follows left and right, but not up and down
(Video of the issue)

		Gun.Barrel.Attachment.CFrame = CFrame.new(Gun.Barrel.Attachment.Position, MousePosition)

^ This is where the rotation is handled.

Try using WorldCFrame and WorldPosition instead.

Once again, same thing happens.

Gun.Barrel.Attachment.WorldCFrame = CFrame.new(Gun.Barrel.Attachment.WorldPosition, MousePosition)

I changed it to CFrame.lookAt and the problem still occurs.
Gun.Barrel.Attachment.WorldCFrame = CFrame.lookAt(Gun.Barrel.Attachment.WorldPosition, MousePosition)

Just curious how are you getting mouse position?

I believe the previous solution I sent should work let me send a repro file soon.

The mouse position is being sent through a remote

Local script:

local MousePosition = Mouse.Hit.p

Remotes.WeaponRemote:FireServer("Flamethrower", Gun, MousePosition)

(There is obviously code in between, but these are the two important lines.)

Seems like something wrong with the remote event then.

Perhaps a server-client difference with the attachment CFrame.

Perhaps you should switch between client and server view in studio to see if there are some differences such as animations and C0 and C1 stuff. I see that the hand of your character is twisted oddly perhaps a C0 and C1 edit which did not replicate.

Otherwise this local script should work tested with default settings and Instances, cannot upload atm keeps erroring for now.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local attachment = script.Parent

local particleEmitter = script.Parent.ParticleEmitter
particleEmitter.EmissionDirection = Enum.NormalId.Front

while true do
	task.wait()
	attachment.WorldCFrame = CFrame.lookAt(attachment.WorldPosition, mouse.Hit.Position)
end
1 Like

So, it seems that it wasn’t a script issue, but was actually because my ParticleEmitter’s Face value was set to left instead of front. Thank you.

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