Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
    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.

0
A loop?? FiredDusk 1466 — 7y
0
What do you mean ? DarkWQlfc 20 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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!

Ad

Answer this question