I am making a FNAF type game on roblox due to boredom, and this doesn’t work how I want it to. I want the camera to not be able to look down, and later in the video linked with this post, it has issues when I look at objects. How would I fix this?
-- // STEPHEX GAMING
turnlimitleft = 0
turnlimitright = 0
watchingcameras = false
local runservice = game:GetService("RunService")
repeat wait() until runservice.Heartbeat ~= nil
currentcam = workspace.CurrentCamera
print("Started breathing.")
local CameraModel = workspace:FindFirstChild("CameraPart")
local plrmouse = game.Players.LocalPlayer:GetMouse()
currentcam.CameraType = "Scriptable"
wait()
while true do
runservice.RenderStepped:Wait()
--print("LEFT: "..turnlimitleft.."")
--print("RIGHT: "..turnlimitright.."")
if turnlimitleft <= 540 and turnlimitright <= 540 then
currentcam.CFrame = CameraModel.CFrame
pos = CFrame.new(CameraModel.Position, Vector3.new(plrmouse.Hit.p.X,0,plrmouse.Hit.p.Z))
if plrmouse.X >= 501 then
turnlimitleft = 0
local tweener = game.TweenService:Create(CameraModel,TweenInfo.new(0.65,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out,0,false,0),{CFrame = pos})
tweener:Play()
--turnlimitright = turnlimitright + 1
end
if plrmouse.X <= 500 then
turnlimitright = 0
local tweener = game.TweenService:Create(CameraModel,TweenInfo.new(0.65,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out,0,false,0),{CFrame = pos})
tweener:Play()
--turnlimitleft = turnlimitleft + 1
end
end
if turnlimitleft >= 41 then
repeat wait() currentcam.CFrame = CameraModel.CFrame until plrmouse.X >= 501
turnlimitleft = 0
end
if turnlimitright >= 41 then
repeat wait() currentcam.CFrame = CameraModel.CFrame until plrmouse.X <= 500
turnlimitright = 0
end
end
Excuse the limit script, I was trying to fix something else but I fixed it by tweening the camera instead. How would I make this work as I want it to?