So, I've been trying to work on a horror game that follows similar mechanics to Amnesia: The Dark Decent.
Atm I've been trying to work on a door and drawer system, such as where you click on the door to open it, and you move your mouse to show how much you want it open. This follows the same with a drawer opening system, where you click, hold, and move your mouse to position how much you want it open, or closed.
I've been having trouble with this, as I haven't been able to get this to work properly, and I also haven't been able to get a max rotation value so the door/drawer doesn't go past its limits.
This is the code I have so far, which I don't think is even the right way to do it:
local Mouse = game.Players.LocalPlayer:GetMouse()
local klik = false
local prev_mousehit
Mouse.Button1Up:connect(function()
klik = false
end)
Mouse.Button1Down:connect(function()
klik = true
end)
Mouse.Move:connect(function()
if klik == true and Mouse.Hit.p ~= prev_mousehit then
game.Workspace.Model.Main.CFrame = game.Workspace.Model.Main.CFrame *
CFrame.Angles(0, -Mouse.X / 80, 0)
prev_mousehit = Mouse.Hit.p
end
end)

5 comments
Sorry, don't have time to write up an answer but I would just use the movement delta of the mouse.
Take the initial 2D position of the mouse and subtract it from the 2D position of the mouse whenever the mouse moves.
Normalize your delta and use that as an Alpha value to calculate how far the door should open. Use the lerp method on the door for the easiest results.
I'll try this out once I finish my Homework, thank you.
Is there anyway I can do this without using InputService?