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

Why my bullet markers are stacking up?

Asked by 4 years ago

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.

01game.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() -- folder with all the bullet holes
04 table.insert(ignoreList,Player.Character) -- player's 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
08--[[
09 local Lazer = Instance.new("Part")
10 Lazer.Parent = game.Workspace
11 Lazer.Anchored = true
12 Lazer.CanCollide = false
13 Lazer.Size = Vector3.new(0.1,0.1,Dist)
14 Lazer.CFrame = CFrame.new(FromP,Position)*CFrame.new(0,0,-Dist/2)
15--]]
View all 38 lines...

Answer this question