Gun Fire Point Problem

Hi, so I made a shot gun. The bullet spawns and rotates where I want it.
image

The problem is this:
image

If I move while shooting the bullet, the bullet kinda just get stuck there right in midair, I want the bullet to be at the gunpoint while I’m still moving is there a way to do that? Sorry is this is a little confusing I tried my best to explain.

Thanks for reading~ :slightly_smiling_face: Hope you can help!

You can try using a beam attached to the gun instead of instancing a part.

then how would the beam do damage?

I’m assuming you are using raycasting?

Yes I am, the raycasting works perfectly fine.

You can use the raycasting to detect a player, you do not need a part for that. Make a beam it’s better and use raycastresult to detect if a humanoid touched or got in the way of the ray

Okay, I will try that! But I’m still stuck with the original problem. Any idea on how to fix?

You can use a beam like I said for a visual representation of the bullet shooting and always being at the gunpoint. Can I see your script that handles the weapon?

Alright, but how can I make the beam look like a part, can you show me an example?

Here’s the script:

local Params = RaycastParams.new()
	Params.FilterDescendantsInstances = {Plr.Character}
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	local Var = false
	local Magnitude = (Pos - Handle.Position).Magnitude
	if  Magnitude < MaxDis then
		for i = 1, 5 do
			local Part = Instance.new("Part")

			Part.Name = "Part"..i
		Part.CanCollide = false
		Part.Anchored = true
		Part.Parent = game.Workspace.Placement
		Part.Size = Vector3.new(0.1,0.1,Magnitude + 1)
			Part.Color  = Color3.fromRGB(255, 255, 0)
			Part.Material = "Neon"
			if Part.Name == "Part1" then
						Part.CFrame =CFrame.lookAt(Handle.Parent.ShootBox.Position, Pos) * CFrame.new(0,0,-Magnitude/2)
			else
				Part.CFrame =CFrame.lookAt(Handle.Parent.ShootBox.Position, Pos + Vector3.new(math.random(-Spread/2, -1),0,math.random(1, Spread/2))) * CFrame.new(0,0,-Magnitude/2)
			end

			local RayCast = workspace:Raycast(Part.Position, Part.CFrame.LookVector * 25,Params)

			if RayCast ~= nil then
				local Humanoid = RayCast.Instance.Parent:FindFirstChild("Humanoid")
				if Humanoid then
				if not Var then
					Humanoid.Health -= 60
						Var = true
					end
				end
			end
			game.Debris:AddItem(Part, 0.1)
			end
		end

–Don’t mind the spread or calculation.

snip
Just like this it would look. Just check the FaceCamera setting in the beam and it should looks something like this.
Your code would be something like this.

local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {Plr.Character}
Params.FilterType = Enum.RaycastFilterType.Blacklist
local Var = false
local Magnitude = (Pos - Handle.Position).Magnitude
if  Magnitude < MaxDis then
	for i = 1, 5 do
        local Part = Instance.new("Part")
        local beam = Instance.new("Beam")
        beam.Color = Color3.fromRGB(255,255,0)
        beam.FaceCamera = true

       local attach1 = Instance.new("attachment")
       attach1.Parent = Part
       local attach2 = Instance.new("attachment")

    	Part.Name = "Part"..i
	    Part.CanCollide = false
	    Part.Anchored = true
	    Part.Parent = game.Workspace.Placement
	    Part.Size = Vector3.new(0.1,0.1,0.1)
        Part.CFrame = CFrame.new(Pos)
        attach2.Parent = Part
        beam.Attachment0 = attach1
        beam.Attachment1 = attach2
        beam.Enabled = true
        beam.Parent = Handle
	end
	local RayCast = workspace:Raycast(Part.Position, Part.CFrame.LookVector * 25,Params)

	if RayCast ~= nil then
			local Humanoid = RayCast.Instance.Parent:FindFirstChild("Humanoid")
			if Humanoid then
			   if not Var then
				   Humanoid.Health -= 60
					   Var = true
			   end
			end
	end
		game.Debris:AddItem(Part, 0.1)
	end
end

I don’t know if this would work since I don’t fully understand where are the variables like Part come from!

Alright thanks for the help. I just have one last question. How do I make the bean thicker?

You can’t lol, unless you make multiple beams. That is why I did the FaceCamera property to true so it looks thick to the player.

1 Like

Why could you not use…?

beam.Width0 = 0-9999
beam.Width1 = 0-9999