Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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)

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. dyler3 1510 — 10y

2 answers

Log in to vote
1
Answered by
hiccup111 231 Moderation Voter
10 years ago

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)
Ad
Log in to vote
-1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

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

Answer this question