Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why is this bullethole not facing the surface direction?

Asked by 4 years ago

I have this hitpart that displays where a bullet was fired (essentially bulletholes), but when it hits, i'm not completely sure how to orient it the way the side of a part it hit was oriented. I assumed it would just do it automatically, I was wrong. My code is here, any help is appreciated

    local hitpart = game.ReplicatedStorage.Hit:Clone()
    hitpart.Position = position
--  hitpart.Orientation = part.Orientation
    hitpart.Parent = game.Workspace
    game.Debris:AddItem(hitpart, 1)

(I commented out the orientation thing since that didn't work either, the part variable is the part it hit)

0
Try to do: hitpart.Orientation = part.Orientation + Vector3.new(0, 90, 0) Soban06 410 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I believe the issue is that you're relying on the part the bullet hits rather than the position of the bullet itself. Both Mouse.Hit and raycasting will give you the CFrame of where the bullet hit (if you're using something like BodyVelocity then you can just use the CFrame of the bullet). You can then use the orientation of the part the bullet hits to determine the orientation of the bullet hole.

If you found this answer helpful, please consider marking as an answer and upvoting!

0
Hey! Thank you for getting back to me, i'm gonna try something like this, but could you be a little more specific? CFrames give me a huge headache and i'm not sure what part of the CFrame i'd be using, also, what about when it hits terrain julianhak06 12 — 4y
Ad

Answer this question