Please help (I don't know how to name this topic)

So basically I want to see if the Parent of the part that is touching the ray is named Katana but I don’t know why the script does not work the way i want it to work. It will simply not see that as a Katana.
the script:

local function RayTest()
	local RAY = Ray.new(Origin.Position,Origin.CFrame.LookVector*3.284)
	local RayPos,HitPos = workspace:FindPartOnRayWithIgnoreList(RAY, IL, false, true)
	print(RayPos)
	if RayPos then
		print("there is a ray pos")
		print(RayPos.Parent)
		if RayPos.Parent:GetFullName() == "Katana" then
			print("It's a katana")
		end	
	end
end

in the output i get this:

KatanaHitbox
there is a ray pos
Katana
but i don’t get the message"It’s a katana"

Thanks,
Tem

https://developer.roblox.com/en-us/api-reference/function/Instance/GetFullName

From the documentary, the function GetFullName() is concatenating (adding together) all the ancestry names and returning it.

If Katana is inside a model called “Weapon”, and Weapon is inside of the workspace. GetFullName() would return “workspace.Weapon.Katana”

So you’re actually comparing “Katana” to “workspace.Weapon.Katana”

To fix this, simply change your if statement to:

if RayPos.Parent.Name == "Katana" then
    print("It's a katana")
end
1 Like

thanks
that solved the issue,
Tem

1 Like