Looking for away to link the mouse.Hit, mouse.Target and it’s respective axis. What i’m trying to do is when a player clicks on a part a new part is made that is at the same x and z position as the mouse.Target.CFrame but at the same y position as mouse.HIt.Position.Y. I have been trying to do this for a few hours now but no combination of CFrames or sizes are giving me a result that works no matter what rotation the mouse.target has I’ve tried to make the position to be at the bottom of the target then times it by the difference in height but i couldn’t get it work effectively and couldn’t find any help online as its quite a specific task.
What i mean :
Script i’m using:
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Hit and mouse.Target and mouse.Target.Parent.Name == "TestingCFrame" then
local target = mouse.Target
local HitPos = mouse.Hit.Position
local part = Instance.new("Part")
part.Size = Vector3.new(target.Size.X+.2,.5,target.Size.Z+.2)
--The Problematic line ;)
part.CFrame = target.CFrame * CFrame.new(0,0--[[replace this 0 with math to move the part up or down depending on where a player clicks]],0)
part.Anchored = true
part.Transparency = .5
part.Parent = target
end
end)
An example place of what i’m trying to accomplish:
TestingCframes.rbxl (53.8 KB)
Thanks in Advance