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

How to make the part follow the mouse while moving the mouse??

	x.CFrame = CFrame.new(char.UpperTorso.Position,Mouse.Hit.p)
	local bv = Instance.new("BodyVelocity", x)
	bv.maxForce = Vector3.new(math.huge,math.huge,math.huge)
	bv.velocity = x.CFrame.lookVector*20

^ This is the lines that involves CFrame and that stuff I know how to make the part go to the mouse's Position but not how to make it follow the mouse after executing it like pressing T and it gets created.

2 comments

0

A loop??

0

What do you mean ?

1 answer

✓ Accepted answer

Make sure you use mouse.target, I would highly recommend only messing with X, and Z. When it comes to Y the part if you hold it still will move towards your camera. If you don't want it to clip then use MoveTo(); Make it run using UserInputService localScript

local Input = game:GetService("UserInputService")
Input.InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.T then
repeat
x.CFrame = CFrame.new(char.UpperTorso.Position,Mouse.Hit.p)
local bv = Instance.new("BodyVelocity", x)
bv.maxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.velocity = x.CFrame.lookVector*20
until game.Players.LocalPlayer:GetMouse().Button1Down
end
end)

Don't quote me from the code I gave you hopefully it works. Goodluck!

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