Trying to insert a part and have it snap to a selected face/Normal/Surface AKA "front,back,top,bottom"
Ive gotten it to work with some scabby code but if someone could let me know if there is an easier way that would be great
Mouse = game.Players.LocalPlayer:GetMouse()
function click()
if script.Parent.Parent.Value.Value == false then
Mouse.Move:Connect(move)
script.Parent.Parent.Value.Value = true
script.Parent.Parent.Parent.BF.Visible = true
script.Parent.BackgroundColor3 = Color3.new(0,0,0)
else
script.Parent.Parent.Value.Value = false
script.Parent.Parent.Parent.BF.Visible = false
script.Parent.BackgroundColor3 = Color3.new(0,0,0)
end
end
function move()
if script.Parent.Parent.Value.Value == true then
print(Mouse.TargetSurface)
end
end
function mouseClick()
if script.Parent.Parent.Value.Value == true then
local Target = Mouse.Target
print(Target.Position)
script.Parent.Parent.SurfaceSelection.Adornee = Target
script.Parent.Parent.SurfaceSelection.TargetSurface = Mouse.TargetSurface
if Mouse.TargetSurface == Enum.NormalId.Front then -- these are my attempts
local a = Instance.new("Part")
a.Parent = game.Workspace
a.Size = Vector3.new(4,4,4)
a.CFrame = CFrame.new(-4,0,0):toWorldSpace(Target.CFrame)
end
if Mouse.TargetSurface == Enum.NormalId.Back then
local a = Instance.new("Part")
a.Parent = game.Workspace
a.Size = Vector3.new(4,4,4)
a.CFrame = CFrame.new(4,0,0):toWorldSpace(Target.CFrame)
end
end
end
Mouse.Button1Down:Connect(mouseClick)
script.Parent.MouseButton1Click:Connect(click)
