I'm trying to find out if there is a way to detect what side of a brick you hit. I'm sure I'm going about this completely wrong and the code posted below will not work. The overall goal was to make it so when the back of a player was hit, it would deal damage. There isn't really a way to reference a hit's Surface though is there?

enabled = true

function onTouch(hit)
	if hit.Parent == nil then return end
	if enabled == true then
		if hit.Parent:FindFirstChild("Humanoid") and hit.Surface == "BackSurface" then
			enabled = false
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 10
		end
	end
end

6 comments

1

id rather just make really thin parts to cover the sides

0

That'd be a way for sure, adding a thin, invisible part on the backside of a player that when it hit damages.

0

I read that article but it didn't do quite what I was hoping. I'm going to go with the method you suggested as a temporary work around. Thanks!

0

I'm assuming this is supposed to be a Touched event? What exactly are you using this for? Raycasting is a good method to look into.

0

I'm sorry, I left the portion showing it was a Touched event. It is. I'm creating a combat system where a player is able to guard against attacks. Obviously though if an attack hits their back I want it to still damage or break the guard.