Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Event script only damages player when ray hits players head?

Asked by
Galicate 106
5 years ago

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)
0
You shouldn't check for the player in Workspace. Use the Character property. User#19524 175 — 5y

Answer this question