I have no idea where to start for this and just need some guidance, how would you make a part rotate to where the mouse is pointing in the workspace?
If you want the part to rotate according to the mouse in someway, this worked for me,
-- LocalScript in StarterPack local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local part = game.Workspace:WaitForChild("RotatePart") mouse.Move:connect(function() part.Rotation = mouse.Hit.p-- makes the rotation the mouses position end)
There is a problem with the above, and that's that when you point your mouse at the sky, or distant objects, it makes the part rotate differently. To fix this, I used the following script,
-- LocalScript in StarterPack local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local part = game.Workspace:WaitForChild("RotatePart") mouse.Move:connect(function() local x = mouse.X local y = mouse.Y local z = (x+y)/2 part.Rotation = Vector3.new(x,y,z) end)
If you however wanted the part to follow the mouse position, you simply get the mouse, and then set the part as the mouses position. Like so,
-- LocalScript in StarterPack local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local part = game.Workspace:WaitForChild("RotatePart") mouse.Move:connect(function() part.CFrame = mouse.Hit-- makes the rotation the mouses position end)
However, the above has a problem with the part flying in your face. To fix this, check if the mouses target is the part. Like so,
-- LocalScript in StarterPack local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local part = game.Workspace:WaitForChild("RotatePart") mouse.Move:connect(function() if mouse.Target ~= part then part.CFrame = mouse.Hit end end)
I how that helped.
Good Luck!