Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make this only affect one side of the part?

I am attempting to only make this affect the bottom portion of the part, but it doesn't work. It just breaks the script completely. Any help?

function onTouch(part)
	local humanoid = part.Parent:findFirstChild("Humanoid")
	if (humanoid ~=nil) then
        if Part.Face = Bottom then
		humanoid.Health = 0
	end
end

script.Parent.Touched:connect(onTouch)

1 comment

0

Sorry, but I don't think there's a way to do this. Someone correct me if i'm wrong, but I pretty sure you can't.

2 answers

The only way ( silly roblox ) to get the face of an object, is to either print it, create an extremely complex script to detect the side, or use a PlayerMouse:

--local script
player = game.Players.LocalPlayer
mouse = player:GetMouse()

mouse.Move:connect(function()
	if mouse.Target then
		print(mouse.TargetSurface)
	end
end)

You cannot perform a Touched Event off of a face of a part. You could try making the part actually be 6 separate parts(For the 6 different sides). And then perform the touched events off of those. Or use Region3 or lookVector to detect where the player is when they touched the part.

Hope I Helped

This discussion is preserved as it was. New answers, comments, and votes are closed.