Raycasting will occasionally not detect that it hit a part.
This script should print a position and a part's name, but randomly the ray doesn't say that it hit a part.
serverside:
game.ReplicatedStorage.OnShootRemote.OnServerEvent:Connect(function(player, bulletOrigin, mouse)
local character = player.Character
local bullet = Ray.new(bulletOrigin, (mouse - bulletOrigin))
local hit, position = workspace:FindPartOnRayWithIgnoreList(bullet, {character.Head, character.Torso}, false, false)
print(position)
if hit then
print(hit.Name)
end
end)
cilentside:
local playerService = game:GetService("Players")
local camera = workspace.CurrentCamera
local localPlayer = playerService.LocalPlayer
local mouse = localPlayer:GetMouse()
mouse.Button1Down:Connect(function()
game.ReplicatedStorage.OnShootRemote:FireServer(camera.Gun.BulletOrigin.CFrame.p, mouse.Hit.p)
end)
video demonstration: https://youtu.be/-X5QWlhzYec
