How do rays make damage?

Im made a Pistol whit raycasting. How can the ray do damage if it hits a player?

You can put a variable to the ray you made.

local rayCastResult = --------


if rayCastResult ~= nil then

    local hum = rayCastResult.Instance.Parent:FindFirstChild("Humanoid")

    if hum then hum:TakeDamage(hum.MaxHealth)
end
2 Likes