Ok so, the player who got hit only takes damage when the ray hits the players head.
The if bodypart.ClassName ~= "Accessory" then is to damage the player of the ray hits an accessory.
function Damage(player, damage, bodypart, playerdamaged, weapon)
if bodypart.ClassName ~= "Accessory" then
workspace[playerdamaged].Humanoid:TakeDamage(damage)
elseif bodypart.ClassName == "Accessory" then
workspace[bodypart.Parent.Parent.Name].Humanoid:TakeDamage(damage)
end
print(player.Name .. " hit " .. playerdamaged .. " in the " .. bodypart .. " and did " .. damage .. " damage using a " .. weapon)
end
game.ReplicatedStorage.DamagePlayer.OnServerEvent:Connect(Damage)

1 comment
You shouldn't check for the player in Workspace. Use the Character property.