Tool changing grip to point towards objects or cursor

I wanna make a tool that changes grip to point towards an object, and I know this isn’t gonna be easy because you have to account for before cframe and then do whatever, anyway how can I do this?

are you telling about cframe.lookat?

hm im not sure but i will see if it will work

it doesnt seem to work for me

local tool = Instance.new("Tool",owner.Backpack)
local handle = Instance.new("Part",tool)
handle.Name = "Handle"
tool.Name = "pointer"

handle.Size = Vector3.new(1,1,2)

tool.Grip = CFrame.new(0,0,1)

local orig = tool.Grip


tool.Activated:Connect(function()
	local a
	a = tool.Deactivated:Connect(function()
		a:Disconnect()
		a = 1
	end)
	
	repeat wait()
		local b = CFrame.lookAt(handle.Position,workspace.Base.Position,CFrame.new().UpVector)
		tool.Grip =	(b-b.Position)
		
	until a == 1
	tool.Grip = orig
end)

i think that you can do this:

create the handle, and a part inside the handle, after this, you use CFrame.lookAt() to point the part to the position.

My solution:

local actived = false

script.Parent.Activated:Connect(function()
	actived = true
	repeat
		local cframe = CFrame.lookAt(script.Parent.Handle.Position, workspace.SpawnLocation.Position)
		script.Parent.Handle.Pointer.CFrame = cframe
		task.wait()
	until actived == false
end)

script.Parent.Deactivated:Connect(function()
	actived = false
end)

while task.wait() do
	script.Parent.Handle.Pointer.Position = script.Parent.Handle.Position
end

yea, i can agree to this as being one of the solutions, but i am wondering about changing tool grip to point towards a cframe or a object. i want it so its not just controlling a anchored part but to control a part that is connected to your character so it looks good and when your moving it wont stay behind

i think that is more simple to do with other part

yes, i know it is but thats my point. i want to make it look better to test my skills and stuff. its just i wouldn’t know how to do it. currently i am thinking of a new method and i will update you if it does work

ok! i hope that i helped u with something :wink:

i have figured it out finally! turns out it was really easy.

local tool = Instance.new("Tool",owner.Backpack)
local handle = Instance.new("Part",tool)
handle.Name = "Handle"
tool.Name = "pointer"

handle.Transparency = .8
handle.Size = Vector3.new(1,1,1)


local showpart = Instance.new("Part",handle)
showpart.Size = Vector3.new(1,1,1)
local weld = Instance.new("Weld",showpart)
weld.Part0 = handle
weld.Part1 = showpart



local demopart = Instance.new("Part",script)
demopart.Anchored = true

function removepos(cf)
	return (cf-cf.Position)
end

tool.Activated:Connect(function()
	local a
	a = tool.Deactivated:Connect(function()
		a:Disconnect()
		a = 1
	end)
	
	repeat
		
		local cf = CFrame.new(handle.Position, Vector3.new(0,0,0))
		
		weld.C0 = removepos(handle.CFrame):ToObjectSpace(removepos(cf))
		
		task.wait()
	until a == 1
	weld.C0 = CFrame.new()
end)

i’m dont very familliar with Welds, but, congratulations for making it!

yes took alot of brain power for me

also the welds are so you can DISPLAY the new cframe. the original handle is just for getting tool cframe. not too complicated.

i dont work with 3D, i’m more familiar with 2D, i’m trying to learn more in 3D, but i think that is too hard for me

ehh, its not too hard. you’ll get used to it. just learn about CFrame and Vector3 and you’ll be fine.

i already have been learned but i still dont familiar with it