so I make a part where it will rotate following the direction of the mouse but it doesn’t work (using Isometric/tilt camera btw)
(expected)
local UserInputService = game:GetService("UserInputService")
local part = script.Parent
local function onInput(input)
local mousePosition = UserInputService:GetMouseLocation()
local angle = math.atan2(mousePosition.Y - part.Position.Y, mousePosition.X - part.Position.X)
part.CFrame = part.CFrame * CFrame.Angles(0, angle, 0)
end
UserInputService.InputChanged:Connect(onInput)
UserInputService does not capture Client mouse movements. You have to use a LocalScript (and it cannot be under workspace) to do so.
LocalScript valid run locations (they can be anywhere in here, including parented to another Instance) are:
Under ReplicatedFirst
Under StarterGui
Under StarterPlayerScripts
and Under StarterCharacterScripts