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

How get part face player is clicking on?

Asked by 4 years ago

I want to make a script where if i click a face of a part it would tell me the face i clicked on. so if i click on the top face it would print "top", if i clicked the front face it would say "front" ect.

code snippet

tool.Equipped:Connect(function(mouse)
    mouse.Button1Down:Connect(function()
        if mouse.Target and mouse.Target.Parent then
            print("face")
        end
    end)
end)
0
Hmm, great question I actually remember reading about this but i forgot. Using rays maybe? starmaq 1290 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

Mouse.TargetSurface

Mouse.TargetSurface gives you a NormalId value which tells you the surface the mouse is on. When it is in the sky, it defaults to Right, so make sure you check if Mouse.Target is existent.

https://developer.roblox.com/api-reference/property/Mouse/TargetSurface

https://developer.roblox.com/api-reference/enum/NormalId

Ad

Answer this question