Bullet doesnt come out of Attachment

So I made a gun script where the beam comes out of the GunFirePoint Attachment in front of the gun. But if I try to click. The beam comes from the middle of the baseplate. Any help? Client Script:

```
local tool = script.Parent

local FirePoint = tool.Handle:FindFirstChild("GunFirePoint")

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()
local BulletFolder = game.Workspace.Bullets
local BulletFireEvent = game.ReplicatedStorage.GunRemotes.MegaGun.MegaGunFire

tool.Activated:Connect(function()
local MousePosition = mouse.Hit.p
local FirePosition = FirePoint.Position
BulletFireEvent:FireServer(MousePosition, FirePosition)
end)
```

This is the server script:

```
--Mega Gun
local MegaGunEvent = game.ReplicatedStorage.GunRemotes.MegaGun.MegaGunFire
local BulletFolder = game.Workspace.Bullets
local debris = game:GetService("Debris")

local range = 200

local function CreateBeam(FirePoint, direction)
	local midpoint = FirePoint + direction/2
	
	local part = Instance.new("Part")
	part.Parent = BulletFolder
	part.Anchored = true
	part.CanCollide = false
	
	part.Material = Enum.Material.Neon
	part.BrickColor = BrickColor.new("Really red")
	
	part.CFrame = CFrame.new(midpoint, FirePoint)
	part.Size = Vector3.new(.5, .5, direction.magnitude)
	
	debris:AddItem(part, 1)
end

MegaGunEvent.OnServerEvent:Connect(function(player, mousePos, firepointPos)
	local Direction = (mousePos - firepointPos).Unit * range
	local Result = workspace:Raycast(firepointPos, Direction)
	
	if Result then
		print(Result.Instance.Name)
	end
	CreateBeam(firepointPos, Direction)
end)
```

Sounds like your CFrame position is messed up. Are you sure your “midpoint” is correct? What about the mousePos and firepointPos? Backtracking and checking your code this way should get you to whatever is causing the positioning issue eventually.

1 Like

Its that I dont understand much about guns. I never made one this is my first try. I don’t understand the midpoint correct

change this to FirePoint.CFrame.Position. Position seems to not work well for tools or the character.

it didnt work. This is what is happening:

Then, I’m not exactly sure what the problem is

1 Like

I tested the script and it seemed to work for me?

I really don’t know. I changed the attachment to a really small part and it fixed it.

Attachments have a WorldCFrame and a WorldPosition property along with their Position and CFrame properties. Instead of getting the attachment’s position (which returns a localized vector) for shooting a bullet, you could instead get the WorldPosition from it instead.