Why my bullet markers are stacking up?
Hello,
As I said in the title,I made a bullet marker script using RayCast but when I shoot to same place multiple times,the bullet holes are stacking up.How can I fix this?Thanks.
01 | game.ReplicatedStorage.RayCastEvent.OnServerEvent:Connect( function (Player, FromP, ToP,Target) |
02 | local RayCast = Ray.new(FromP,(ToP-FromP).unit* 100 ) |
03 | local ignoreList = workspace.bh:GetChildren() |
04 | table.insert(ignoreList,Player.Character) |
05 | local Part,Position,Normal = game.Workspace:FindPartOnRayWithIgnoreList(RayCast,ignoreList, false , true ) |
06 | local Dist = (ToP-FromP).magnitude |
07 | if not Dist then Dist = 300 end |
16 | local Hole = game.ReplicatedStorage.Hole:Clone() |
17 | Hole.Parent = Part.Parent |
19 | Hole.CFrame = CFrame.new(Hole.Position, Hole.Position+Normal) |
21 | local Weld = Instance.new( "Weld" ) |
24 | Weld.C 0 = Part.CFrame:Inverse() |
25 | Weld.C 1 = Hole.CFrame:Inverse() |
27 | game.Debris:AddItem(Hole, 10 ) |