So I’ve made a thingy that rotates the humanoidRootPart based on the last mouse x
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local LastMousePositionX = nil
local Sensitivity = 2
local Dummy = game.Workspace.bob
UserInputService.InputBegan:Connect(function(Input, GameProcessed)
if not GameProcessed and Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
LastMousePositionX = Mouse.X
end
end)
UserInputService.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
LastMousePositionX = nil
end
end)
UserInputService.InputChanged:Connect(function()
if LastMousePositionX then
local YOrientation = (Mouse.X - LastMousePositionX) / Sensitivity
if YOrientation >= 180 then
repeat
YOrientation = YOrientation - 180
until YOrientation <= 180
end
Dummy.HumanoidRootPart.Orientation = Vector3.new(0, YOrientation, 0)
end
end)
It works but the dummy goes spiral for some reason and sometimes the dummy doesn’t move/rotates at all
Example:
help