No, I mean that only when my cursor is hovering over the part it rotates but when it is not hovering over the part it doesn’t rotate. I want it to rotate even when I am not hovering over the part.
Sorry, I misread what you were saying.
There are two ways to accomplish what you want to do. The first method assumes that your mouse is locked in place on the screen, like you are in first person or holding MouseButton2 to rotate your camera. You can assign a variable to the InputChanged event that will rotate the part using the input.Delta from said event. You can also disconnect it when certain conditions are met:
local UserInputService = game:GetService("UserInputService")
local inputChanged
-- Assign event to variable so we can disconnect it later
inputChanged = UserInputService.InputChanged:Connect(function(input, processed)
-- Do nothing if this input was processed by the game
if processed then return end
-- If the input is the mouse moving
if input.UserInputType == Enum.UserInputType.MouseMovement then
wall.CFrame *= CFrame.Angles(0, input.Y, 0)
end
end)
-- Disconnect
task.wait(5)
inputChanged:Disconnect()
Or what if the players mouse isn’t locked, you can do this although I don’t recommend it as the method to getting the mouse is outdated:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local lastY = mouse.Y
local move
-- Assign event to variable so we can disconnect it later
move = mouse.Move:Connect(function()
wall.CFrame *= CFrame.Angles(0, mouse.Y - lastY, 0)
-- Update lastY for the next Move event
lastY = mouse.Y
end)
-- Disconnect
task.wait(5)
move:Disconnect()