Dear all, I am doing raycasting. Here is my code:
local Rep = game:GetService("ReplicatedStorage") local Shoot = Rep.Pistol.ShootEvent
Shoot.OnServerEvent:Connect(function(plr, Pistol, MouseP)
--local ray = Ray.new(Pistol.FirePoint.Position, Vector3.new(0, 90, 0))
local ray = Ray.new(Pistol.FirePoint.Position, (MouseP - Pistol.FirePoint.Position).Unit * script.Parent.Range.Value)
local hit,position = workspace:FindPartOnRayWithIgnoreList(ray, Pistol:GetChildren(), false, true)
if hit then
print(hit.Name)
end
local Part = Instance.new("Part",game.Workspace)
Part.Position = MouseP
Part.Size = Vector3.new(0.0001,0.0001,0.0001)
Part.CanCollide = false
Part.Transparency = 1
Part.Anchored = true
Part.Name = "HitPoint"
local At1 = Instance.new("Attachment",Part)
local At2 = Instance.new("Attachment",Pistol.FirePoint)
local Beam = Instance.new("Beam",game.Workspace.HitPoints)
Beam.Attachment0 = At2
Beam.Attachment1 = At1
Beam.Width0 = 0.2
Beam.Width1 = 0.2
Beam.LightEmission = 30
wait(0.3)
Beam:Destroy()
Part:Destroy()
At1:Destroy()
At2:Destroy()
Pistol.FirePoint.Gunfire:Play()
--local ray = Ray.new(p1, (p2 - p1).Unit * Distance)
end)
I want to ignore more than Pistol:GetChildren. I wanna ignore the HitPoint, Your own character, and also want to have a good way to add new ignores in the future. The thing is I am using Pistol:GetChildren() but I also wanna do the local players character:GetChildren() and finally the HitPoint. How do I do this?
