Bullets not starting on tip of the gun

I was making my first gun but the bullet does not start at the tip of the barrel. I was trying to make it look like Big PaintBall where you can clearly see where it starts but I do not know how.

function Look_At(TiP, Position)
	local face_direction = (Tip.CFrame.p - Position).unit
return CFrame.lookAt(Tip.CFrame.p - Vector3.new(0,0,2), Position)

newBullet.CFrame = Look_At(Tip.CFrame.p, Laser.Position) 

local speed = (Laser.Position - Tip.CFrame.p).Unit * 600

newBullet.Velocity =  speed
end



1 Like

the first parameter of lookat is the position, correct however your position is where you mess up. I don’t know what this “laser.Position” specifically is but if i suspect it is the thing you are moving then this will be a recursive loop. Anyways My point is you should replace Laser.Position with a vector generated from the head and tail of the vector you used to generate the ray

The laser position is where the ray ends. Such as the laser touching an object or how long it is without hitting.

I guess multiply the lookat function by a cframe of the guns position

Use just CFrame or CFrame.p?
30

function Look_At(TiP, Position)
	local face_direction = (Tip.CFrame.p - Position).unit
return CFrame.lookAt(Tip.CFrame.p - Vector3.new(0,0,2), Position)
end

newBullet.CFrame *= Look_At(Tip.CFrame.p, Laser.Position) 

local speed = (Laser.Position - Tip.CFrame.p).Unit * 600

newBullet.Velocity =  speed

If you don’t mind me asking how would this work?

basically we get the orientation the cframe should be with the look at thing then we combine those matricies together *= is basically newBullet.CFrame = newBullet.CFrame * Look_At(params)

Thanks but it would not work it would just spawn somewhere else and not on the handle.

Could anyone help since using these paintball guns in close range would not work since the bullet is too fast which makes it spawn further.

I would suggest just looking up a tutorial. Its hard to find a solution when we don’t have much code to go off of. Heres some tutorials:

Roblox Gun Tutorial - How To Make A Gun - YouTube
Working Simple Gun Tutorial ROBLOX Studio 2020 - YouTube
ROBLOX simple hit-scan gun tutorial - YouTube

Most of the code in my opinion is not important in the question I am asking but if you want to see the code I could show you.

Either way those won’t work since the ray-cast starts at the bullet.