Make Bullet Hole

Im trying to make a bullet hole script where it positions and rotates a part to the face where the player shot. im attempting to make it unanchrored and attached with some kind of weld, so that when the shot part moves, the bullet hole moves with it. I have access to mouse.Target(CFrame) and mouse.Hit.Position(Vector3)

im not sure how to raycast, so if you do have any ideas with raycast, please share!

Use raycast.Normal

in this context: Bhole.CFrame = CFrame.new(Bhole.Position, Bhole.Position + raycast.Normal)

Bhole = the bullet hole
To get the raycast to work do something like:

local mousePos = uis:GetMouseLocation()
	local unitRay = cam.ViewportPointToRay(cam, mousePos.X, mousePos.Y)
	
	local cast = workspace:Raycast(unitRay.Origin, unitRay.Direction * 400, params)
	
	if cast then

where as uis is userinputservice and cam is the workspace.CurrentCamera

Maybe I’m wrong, but Mouse.hit uses raycasts right? So you’re doing “raycasting” without even knowing lol.

But @emiliotigre2017 's method is better according to the documentation.

My method is indeed better as you have access to the normals and it has basically everything :GetMouse() has

1 Like

Plus you can filter out more instances with UIS, unlike mouse.TargetFilter as it only filters out one instance and it’s descendants.

thank you so much, this means alot!

1 Like

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