So my gun script gives me no errors but when i shoot at someone it dosen’t damage it most of the time
i’ve tried alot, at first i thought that it was hitting the player even though i ignored it but that wasn’t it
so i don’t know what to do, please help
raydirection = mouse.Hit.p - cam.CFrame.Position
result = workspace:Raycast(cam.CFrame.Position, raydirection, newray)
if result then
print(result.Instance.Name)
game.ReplicatedStorage.ShootGun:FireServer(result, vm.Damage.Value)
end
This may be happening because you’re sending the raycast to the Mouse’s target position, which means that it may not intercept the part you’re aiming at. You can likely resolve this by passing Mouse.Target (returns the part that the mouse is targeting) into the RemoteEvent if result is nil.