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

How do I make a part point in the direction of the mouse, using CFrame? [SOLVED]

Asked by
Minifig77 190
10 years ago

I'm trying to make a realistic gun, and the bullets are propelled using lookVector. The thing with lookVector is is that the bullet has to be facing the target destination, in this case, where the mouse is pointing. This brings me back to the original question: How do I make a part point in the same direction that the mouse is pointing in?

0
Anyone? Minifig77 190 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

No guarantees, but:

game:GetService("RunService").Stepped:connect(function()
part.CFrame=CFrame.new(part.CFrame.p, mouse.Hit.p)
end)

That SHOULD work, as it's something i've been using in my code for a while, just simplified. To work correctly, the part must be anchored.

Ad

Answer this question