This is my first topic.
Here is the current code I got:
local dx, dy = 0, 0 -- in degrees
local MouseSensitivity = 0.1
local UserInputService = game:GetService("UserInputService")
local Mouse = game.Players.LocalPlayer:GetMouse()
local og=CFrame.new(41.0570641, 5.84983873, -6.92497635, 1, 0, -0, -0, 1, -0, -0, 0, 1)
local cam=workspace.CurrentCamera
local lastmove=false
local tweenog=true
function UpdateModel()
cam.CFrame = cam.CFrame:lerp(CFrame.new(og.Position)
* CFrame.fromOrientation(math.rad(math.clamp(dx,-90,90)), math.rad(math.clamp(dy,-90,90)), 0),.1)
end
function MouseMove()
local Delta = UserInputService:GetMouseDelta()
dx += Delta.Y * MouseSensitivity
dy += Delta.X * MouseSensitivity
UpdateModel()
end
function MouseDown()
if lastmove then
tweenog=true
end
lastmove=true
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
end
function MouseUp()
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
wait(3)
if lastmove and tweenog then
tweenog=false
lastmove=false
dx=0
dy=0
game:GetService("TweenService"):create(cam,TweenInfo.new(1),{CFrame=og}):play()
end
end
Mouse.Move:Connect(MouseMove)
Mouse.Button1Down:Connect(MouseDown)
Mouse.Button1Up:Connect(MouseUp)
However, I fiddled around with some bools to make the camera retract (with tweening) back to its original cframe when not touched for 3 seconds, but itβs glitchy.
Help would be much appreciated!
Here is the current horror game with the camera movement:
https://www.roblox.com/games/6147303787/Malware