[Fixed] OnDamage fails to receive HitResult part name

Describe the bug:

When a raycast intersects with a character entity, the hitResult contains the part that the ray intersected with. For example, if the ray intersected with the player’s head, then hitResult:GetPartName() would return Head.

If you call ApplyDamage(0, hitResult, Vector.Zero, entity), then print hitResult:GetPartName() in the OnDamage entry point on a character script, the part name will be empty.

How do you cause this bug?

I’ve created a reproduction here, with the part names logged to the standard notification log.

If you want to recreate the bug manually, create an object that “shoots” a ray periodically, and call ApplyDamage in the callback.

local ShootScript = {}

ShootScript.Properties = {
	{ name = "exitLocator", type = "entity" }

function ShootScript:Init()
	local start = self.properties.exitLocator:GetPosition()
	local stop = start + (self.properties.exitLocator:GetForward() * 1000)
		while true do 
			GetWorld():Raycast(start, stop, {}, function(entity, hitResult)
				if entity and entity:GetUser() then 
					entity:GetUser():SendToScripts("AddNotification", FormatString("ApplyDamage: {1}", hitResult:GetPartName()))
				entity:ApplyDamage(1, hitResult, (entity:GetPosition() - start):Normalize(), self:GetEntity())

return ShootScript
local BugScript = {}

function BugScript:Init()

function BugScript:OnDamage(amt, fromEntity, hitResult)
	self:GetEntity():GetUser():SendToScripts("AddNotification", FormatString("OnDamage: {1}", hitResult:GetPartName()))

return BugScript

Your Crayta username: Cereal

Game seen in (including “Hub” or “Editor for XYZ”): Crayta

How regularly do you see this? (E.g. 2/3 times - please try 3 times if possible): Every time

Time + date seen: March 09 2022

Version number (found in Help tab in Settings): 0.e5.40.115857

1 Like

Hey there @Cereal !

Great to see those scripts! Thank you very much for helping us out with all the details!
I have gone ahead and opened up a ticket for our internal team to take a look further into this for you. :slight_smile:

1 Like


This bug has been resolved as of the latest update. Patch notes can be found here:Patch Notes: Cursed Galleons Launch!

Let us know if you believe the issue to still be present!