game.ReplicatedStorage.RayCast.OnServerEvent:Connect(function(player,exit,mousehit)
local debounce = false
local ray = Ray.new(exit.Position, (mousehit.Position - exit.CFrame.Position).unit * 500)
local part,position = workspace:FindPartOnRay(ray,player.Character,false,false)
local bullet = Instance.new("Part",workspace)
bullet.Material = Enum.Material.Neon
bullet.BrickColor = BrickColor.new("Bright yellow")
bullet.CanCollide = false
bullet.Anchored = true
bullet.Name = "Ak-47 Bullet"
local distance = (exit.Position - position).magnitude
bullet.Size = Vector3.new(-8.855, 0.025,distance)
bullet.CFrame = CFrame.new(exit.Position, position) * CFrame.Angles(math.rad(math.random(0,5)),math.rad(math.random(0,9)),0) * CFrame.new(0,0,-distance / 2)
bullet.Touched:Connect(function(hit)
print(hit)
end)
end)
The Touched event does not detect the dummy or baseplate, it only detects the children of the tool and children of my player. How do i fix this?

1 comment
Well, you're telling the ray to find player.Character when you use FindPartOnRay(). You should try to assign parameter 2 to a generic rig and not a locked one like player.Character.