local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
-- Check that there exists a part at which the mouse is pointing
while wait(.5) do
if mouse.Target then
print("The mouse is pointing to the " .. mouse.TargetSurface.Name .. " side of " .. mouse.Target.Name)
local focus = mouse.Target
local PartSize = 4
local deltaz, deltax, deltay = 2,2,2
-- if mouse.TargetSurface.Name == "Top" then
-- deltaz, deltax, deltay = 0,PartSize,0
-- elseif mouse.TargetSurface.Name == "Bottom" then
-- deltaz, deltax, deltay = 0,-(PartSize),0
-- elseif mouse.TargetSurface.Name == "Left" then
-- deltaz, deltax, deltay = PartSize,0,0
-- elseif mouse.TargetSurface.Name == "Right" then
-- deltaz, deltax, deltay = 0,-(PartSize),0
-- elseif mouse.TargetSurface.Name == "Front" then
-- deltaz, deltax, deltay = 0,0,PartSize
-- elseif mouse.TargetSurface.Name == "Back" then
-- deltaz, deltax, deltay = 0,0,-(PartSize)
-- end
local pos = focus.Position + (Vector3.FromNormalId(Enum.NormalId.Front)*deltaz) +(Vector3.FromNormalId(Enum.NormalId.Right)*deltax)+(Vector3.FromNormalId(Enum.NormalId.Top)*deltay)
print(pos)
-- if pos.X > 4 or pos.Y > 4 or pos.Z > 4 then
-- pos = Vector3.new(0,0,0)
-- end
game.Workspace.Grass.Position = pos
else
print("The mouse is not pointing at anything.")
end
end
I'm trying to move the part to the correct side of the other part based on mouse.TargetSurface but instead it does this:(https://gyazo.com/217feb4a923d2c52b3fc6163bc08b060) The parts are 4x4x4

3 comments
I would get the rightVector, upVector, and lookVector of the part. Correspond that with the side of the part and CFrame accordingly.
Yeah i kinda knew that but how would i do it?
Nvm i figured it out