How to tell if clicked on a half of part

the title doesn’t do this justice cause I am super lost

if hitpos.Y <= target.Position.Y + target.Size.Y/2 and hitpos.Y >= target.Position.Y then
	targetpoint = "Upper"
elseif hitpos.Y >= target.Position.Y - target.Size.Y/2 and hitpos.Y <= target.Position.Y then
	targetpoint = "Lower"
end

this only works if its standing straight up


as seen here if laying down it screws up and I cant think of how to fix it.
please I beg of whoever can help, help please.

2 Likes

it registers hitpost.Y but while the npc is laying down its all the same Y position

1 Like

i know but i cant think of another way to get what I need, yk?

Like this?

local Mouse = game.Players.LocalPlayer:GetMouse()

Mouse.Button1Down:Connect(function()
	local hitpos = Mouse.Hit.Position
	local target = Mouse.Target
	
	local RelativeHit = target.CFrame:PointToObjectSpace(hitpos)
	if RelativeHit.Y >= 0 then
		print("Upper")
	else
		print("Lower")
	end
end)
1 Like

Technically the code block in the top tells if its hit the upper or lower area but it only works if the model/part is standing straight up. Does this check its local axis cause idk what that cframe line is lol.
edit: I made this reply on my phone so I couldn’t test it. thank you very much

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.