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.
game.ReplicatedStorage.RayCastEvent.OnServerEvent:Connect(function(Player, FromP, ToP,Target) local RayCast = Ray.new(FromP,(ToP-FromP).unit*100) local ignoreList = workspace.bh:GetChildren() -- folder with all the bullet holes table.insert(ignoreList,Player.Character) -- player's character local Part,Position,Normal = game.Workspace:FindPartOnRayWithIgnoreList(RayCast,ignoreList, false,true) local Dist = (ToP-FromP).magnitude if not Dist then Dist = 300 end --[[ local Lazer = Instance.new("Part") Lazer.Parent = game.Workspace Lazer.Anchored = true Lazer.CanCollide = false Lazer.Size = Vector3.new(0.1,0.1,Dist) Lazer.CFrame = CFrame.new(FromP,Position)*CFrame.new(0,0,-Dist/2) --]] local Hole = game.ReplicatedStorage.Hole:Clone() Hole.Parent = Part.Parent Hole.Position = ToP Hole.CFrame = CFrame.new(Hole.Position, Hole.Position+Normal) local Weld = Instance.new("Weld") Weld.Part0 = Part Weld.Part1 = Hole Weld.C0 = Part.CFrame:Inverse() Weld.C1 = Hole.CFrame:Inverse() Weld.Parent = Hole game.Debris:AddItem(Hole,10) -- game.Debris:AddItem(Lazer,0.2) --[[ if Part and Part.Parent:FindFirstChild("Humanoid") then Part.Parent.Humanoid:TakeDamage(30) end --]] end)