Attempting at using AlignPosition to move stuff but when I try to move a BasePart with a MeshPart and a WeldConstraint, it just doesn’t move.
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {game.Players.LocalPlayer.Character}
function hoveringOverItem()
local mouseLocation = UserInputService:GetMouseLocation()
local origin = workspace.CurrentCamera.CFrame.Position
local ray = workspace:Raycast(origin, workspace.CurrentCamera.CFrame.LookVector * 10, raycastParams)
if ray then
if ray.Instance.Parent.Name == 'Plate' or ray.Instance.Parent.Parent.Name == 'Plate' then
return true, ray.Instance:FindFirstAncestor('Plate')
end
if ray.Instance.Parent.Name == 'Cheese' then
print('Cheese???')
return true, ray.Instance.Parent
end
return true, ray.Instance
end
end
local function press(input, gpa)
if gpa then return end
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
if renderSteppedConnection ~= nil then return end
local hovering, instance = hoveringOverItem()
if hovering and not instance:FindFirstChild('CarriedBy') and instance:FindFirstAncestor('Items') then
carryControls.Visible = true
doorControls.Visible = false
grillProgress.Visible = false
carrying = instance
print(carrying)
alignPosition = script.AlignPosition:Clone()
alignPosition.Attachment0 = carrying:FindFirstChild('Attachment')
alignPosition.Parent = carrying
alignOrientation = script.AlignOrientation:Clone()
alignOrientation.Attachment0 = carrying:FindFirstChild('Attachment')
alignOrientation.Parent = carrying
highlight = Instance.new('Highlight')
highlight.FillTransparency = 1
highlight.OutlineColor = Color3.new(0, 0, 0)
highlight.OutlineTransparency = 0
highlight.Adornee = carrying
highlight.DepthMode = Enum.HighlightDepthMode.Occluded
highlight.Parent = carrying
if carrying:FindFirstChild('Mesh') then
highlight.Adornee = carrying:FindFirstChild('Mesh')
end
-- carrying.CanCollide = false
carryRemote:FireServer(instance)
renderSteppedConnection = game:GetService('RunService').RenderStepped:Connect(function()
local position, normal = raycast()
alignOrientation.CFrame *= CFrame.Angles(math.rad(vertical*5), math.rad(horizontal*5), 0)
if normal then
alignPosition.Position = position + (normal * (instance.Size / 2))
else
alignPosition.Position = position
end
end)
if renderSteppedDoorConnection ~= nil then
renderSteppedDoorConnection:Disconnect()
renderSteppedDoorConnection = nil
end
if renderSteppedProgressConnection ~= nil then
renderSteppedProgressConnection:Disconnect()
renderSteppedProgressConnection = nil
end
end
end