I'm creating a program where you need to know which side of the part is clicked
, to determine the orientation of an object that will be attached to the part. The rest I can take care of, but I'm not sure how to get the exact side of the part (i.e, TopSurface
, RightSurface
, LeftSurface
, etc - but with position).
The code itself should print the side of the part that was clicked with the user's mouse, but I have no idea how I'd go about doing this. Here is how I planned on it looking:
local PlayerService = game:GetService'Players' local Player = PlayerService.LocalPlayer local Mouse = Player:GetMouse() Mouse.Button1Down:connect(function() local Target = Mouse.Target if Target and Target:IsA("BasePart") then local MousePos = Mouse.Hit.p local PartSide -- Where it calculates the side of the part that's clicked print(PartSide) -- Print the position, string, or anything that represents the side of the part that was clicked. end end)
If anyone has any insight on how I could go about solving this, it'd be much appreciated!
All you needed to do was just do Mouse.TargetSurface I made my own building system and at first needed to know the Target Sides then I find that Roblox had a way to get what side the Target is.
local PlayerService = game:GetService'Players' local Player = PlayerService.LocalPlayer local Mouse = Player:GetMouse() Mouse.Button1Down:connect(function() local Target = Mouse.Target if Target and Target:IsA("BasePart") then local MousePos = Mouse.Hit.p local PartSide = Mouse.TargetSurface -- Where it calculates the side of the part that's clicked -- To check what it equals then do PartSide == Enum.NormalId.Front print(PartSide) -- Print the position, string, or anything that represents the side of the part that was clicked. end end)