Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make this Axis tool move not only the parts but the full model?

I've found an axis tool that is great and it works nice but It literally only grabs parts, like if a model had 2 parts it would grab only one part and not the full model, how would I get this to work with not just the parts but also grab models? I can't find the area in the code that states what its grabbing


local Tool = script.Parent

enabled = true

local selectionBox
local moveHandles

local selectedPose
local previousCFrame
local previousDistance

function onMoveHandlesDown(normal)
	print("handlesDown")
	if selectedPose then
		previousDistance = 0
	end
end

function onMoveHandlesDrag(normal, distance)
	if selectedPose then
		local delta = distance - previousDistance
		translation = CFrame.new(Vector3.FromNormalId(normal) * delta)
		selectedPose.CFrame = translation * selectedPose.CFrame
		previousDistance = distance

		print(selectedPose.Position)
	end
end


function onButton1Down(mouse)
	print("3DButtonDown")
  
	selectionBox.Adornee = nil
	moveHandles.Adornee = nil

	if mouse.Target ~= nil then
if not mouse.Target.Locked then
		selectedPose = mouse.Target
		selectionBox.Adornee = mouse.Target
		moveHandles.Adornee = mouse.Target
	end
end
end


function onEquippedLocal(mouse)
	local character = script.Parent.Parent
	local player = game.Players:GetPlayerFromCharacter(character)

	mouse.Icon ="rbxasset://textures\\DragCursor.png"
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)

	selectionBox = Instance.new("SelectionBox")
	selectionBox.Color = BrickColor.new("Cyan")
	selectionBox.Adornee = nil
	selectionBox.Parent = player.PlayerGui

	moveHandlesPart = Instance.new("Part")
	moveHandlesPart.Name = "MoveHandlesProxyPart"
	moveHandlesPart.Size = Vector3.new(2,2,2)
	moveHandlesPart.Parent = player.PlayerGui
  
	moveHandles = Instance.new("Handles")
	moveHandles.Style = Enum.HandlesStyle.Movement
	moveHandles.Color = BrickColor.new("Neon orange")
	moveHandles.Adornee = nil
	moveHandles.MouseDrag:connect(onMoveHandlesDrag)
	moveHandles.MouseButton1Down:connect(onMoveHandlesDown)
	moveHandles.Parent = player.PlayerGui
end

function onUnequippedLocal()
	selectionBox:Remove()
	moveHandles:remove()
end


Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)

1 answer

Use Model:SetPrimaryPartCFrame(CFrame) instead of Part.CFrame =

You'll probably want to look at line 23 to make the switch

1 comment

0

Where do you see Part.CFrame = ?

This discussion is preserved as it was. New answers, comments, and votes are closed.