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

make part rotate to cursor?

i want a part to rotate to cursor via Orientation; no CFrame witchcraft. can anybody help me with this?

1 answer

Eh, you need some CFrame witchcraft. But it's fairly simple to do!


One of the constructors of a CFrame is as follows:

CFrame.new ( Vector3 Position, Vector3 LookAt )

For example:

CFrame.new(Vector3.new(0, 10, 0), Vector3.new(5, 0, 0))

Will create a CFrame located at {0, 10, 0}, oriented towards {5, 0, 0}. And that's all! Now all that's left is to plug in what you know already:

-- Local script
local mouse = game.Players.LocalPlayer:GetMouse()
local part = workspace.Part

mouse.Move:Connect(function()
	part.CFrame = CFrame.new(part.Position,mouse.Hit.Position)
end)

Hope I helped!

10 comments

0

well

0

ok

0

well i need the orientation mainly for the fact that im doing a CFrame free game but thanks anyways

0

accept the answer plox

0

im sorry dude

0

but it needs to b without cframe

1

U simply cant.

0

Would you rather make an algorithm to point a rotation vector at a position vector? I don't think so. CFrame.new(pos, look) is as easy as it gets.

0

actually yes

0

its not for performance or anyting its a personal challenge. if u dmonstrate what u said ill accept it

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