Hello , how can I make a script detect that the pistol bullet (which is anchored) hits a wall? that could solve a lot of problem in my games.
You can use raycast that shoots toward the direction the bullet is going, and detect the wall with it
i found how i can do that :) :
local function ClosestPointOnPart(Part, Point) --by sircfenner local Transform = Part.CFrame:pointToObjectSpace(Point) local HalfSize = Part.Size * 0.5 return Part.CFrame * Vector3.new( -- Clamp & transform into world space math.clamp(Transform.x, -HalfSize.x, HalfSize.x), math.clamp(Transform.y, -HalfSize.y, HalfSize.y), math.clamp(Transform.z, -HalfSize.z, HalfSize.z) ) end while true do script.Parent.BulletTouch.Value = false --reset value local Part1 = workspace.Map local Part2 = script.Parent.Parent.Bullet local par1 = ClosestPointOnPart(Part1, Part2.Position) local par2 = ClosestPointOnPart(Part2, Part1.Position) if (math.floor((par1 - par2).Magnitude * 10))/10 < 0.51 then script.Parent.BulletTouch.Value = true end wait(0.025) end