Making a part point towards mouse without CFrame

Sorry for my english i’m using a translator

Hello, recently i was working on a hook that makes the player go towards mouse, and it worked pretty well but when i tried to make the player points towards mouse while moves towards it the player gets stuck because i’m using CFrame for making the player points towards it and it makes the player get stuck.

local Connection

RemoteEvent.OnServerEvent:Connect( function(Client, MouseHitp, RootPart)

	local BodyVelocity = Instance.new("BodyVelocity")
	
	BodyVelocity.Parent = RootPart
	BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	
	local VelocityMultiplier = 50
	
	Connection = RunService.Stepped:Connect( function()

		-- Making the root part point to the mouse makes it get stuck because it set its position to its position but i don't know another way to make the root part point to the mouse

		BodyVelocity.Velocity = CFrame.new(RootPart.Position, MouseHitp).LookVector * VelocityMultiplier
		
		RootPart.CFrame = CFrame.new(RootPart.Position, MouseHitp)
	end)

Is there another way to make a part point to a position without getting stuck?

I would suggest using a bodymover (such as a bodygyro) instead of CFrame lookat to poin towards the part. Since you are manipulating the positio through a bodymover, why not the rotation too? (Ignore the AngularRotation stuff on the webpage)

1 Like

I tried doing like this but it didn’t worked:

Edit: The root part doesn’t point to the mouse

local Connection

RemoteEvent.OnServerEvent:Connect( function(Client, MouseHitp, RootPart)
	
	local RedDot = ServerStorage.RedDot:Clone()
	
	RedDot.Parent = game.Workspace
	RedDot.Position = MouseHitp

	local BodyVelocity = Instance.new("BodyVelocity")
	
	BodyVelocity.Parent = RootPart
	BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	
	local BodyGyro = Instance.new("BodyGyro")

	BodyGyro.Parent = RootPart
	BodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
	BodyGyro.P = 1000
	
	local VelocityMultiplier = 50
	
	Connection = RunService.Stepped:Connect( function()
		
		BodyVelocity.Velocity = CFrame.new(RootPart.Position, MouseHitp).LookVector * VelocityMultiplier
		
		BodyGyro.CFrame = CFrame.new(RootPart.Position, MouseHitp)
	end)
end)

Try this:

local Connection

RemoteEvent.OnServerEvent:Connect( function(Client, MouseHitp, RootPart)
	
	local RedDot = ServerStorage.RedDot:Clone()
	
	RedDot.Parent = game.Workspace
	RedDot.Position = MouseHitp

	local BodyVelocity = Instance.new("BodyVelocity")
	
	BodyVelocity.Parent = RootPart
	BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	
	local BodyGyro = Instance.new("BodyGyro")

	BodyGyro.Parent = RootPart
	BodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
	BodyGyro.P = 8000
	
	local VelocityMultiplier = 50
	
	Connection = RunService.Stepped:Connect( function()
		
		BodyVelocity.Velocity = CFrame.lookAt(RootPart.Position, MouseHitp).LookVector * VelocityMultiplier
		
		BodyGyro.CFrame = CFrame.lookAt(RootPart.Position, MouseHitp)
	end)
end)

If that doesn’t work, try learning from this code:

It worked but it’s rotating too slow so i need to lower the damping like the link you sent says, yes?

You are probably correct. You might also want to decrease or increase power depending on it.