When i raycast with the gun i’m making, for some reason the ray only hits the humanoid root part, but passes through any other part in a character. The visualised ray hits where it is supposed to though so it doesn’t make sense:
(first image damaged player, hit part according to output is workspace.Player.HumanoidRootPart, so thats good)
(second image didn’t damage player even though it is supposed to, hit part according to output is wokspace.Map.MeshPart which is one of the parts making up the border of the map, note how the visualised raycast stops just before the character’s head)
script that does the raycasting:
fireEvent.OnServerEvent:Connect(function(player,FromP,ToP)
local RayCast = Ray.new(FromP,(ToP-FromP).unit*500)
local ignorelist = workspace.Map.Spawns:GetChildren()
table.insert(ignorelist,player.Character)
local Part,Position = game.Workspace:FindPartOnRayWithIgnoreList(RayCast,ignorelist)
local Dist = (ToP-FromP).magnitude
if not Dist then Dist = 500 end
local Lazer = Instance.new("Part")
Lazer.Parent = game.Workspace
Lazer.Anchored = true
Lazer.CanCollide = false
Lazer.Color = Color3.fromRGB(255, 247, 0)
Lazer.Transparency = 0.5
Lazer.Size = Vector3.new(0.1,0.1,Dist)
Lazer.CFrame = CFrame.new(FromP,Position)*CFrame.new(0,0,-Dist/2)
game.Debris:AddItem(Lazer,0.2)
if Part and Part.Parent:FindFirstChild("Humanoid") then
damagePlayer(player,Part.Parent)
elseif Part and Part.Parent.Parent:FindFirstChild("Humanoid") then
damagePlayer(player,Part.Parent.Parent)
end
print(Part:GetFullName())
local amount = 2.5
reloadFunc:InvokeClient(player,amount)
fireEvent:FireClient(player)
end)
i tested the ray hitting the player’s arm and legs and they both do the same as image 2 (looks like it hit but it didn’t)
the problem isn’t to do with the map, i have tested it on different maps and a baseplate and the problem still happens