Hey guys, so I am trying to get it so that if the mouse targets a frame, the camera view changes to fit the left or right place, so it gives you a "Look around" can anyone see why it gives me this?: 22:01:12.063 - Workspace.Player1.Helicopterseeing:21: attempt to index local 'mousetarget' (a nil value) here is the script:
local camera = game.Workspace.CurrentCamera
local target = game.Workspace.Heli.Heli1
local target2 = game.Workspace.Heli.Heli2
camera.CameraType = "Scriptable"
camera.CameraSubject = target2
camera.CoordinateFrame = CFrame.new(target2.Position)
* CFrame.Angles(0, math.rad(90), 0)
wait(0.1)
game.Players.LocalPlayer.PlayerGui.TalkGui.script1.Disabled = false
while wait() do
if script.Heli3Ready.Value == true then
camera.CameraSubject = target
camera.CoordinateFrame = CFrame.new(target.Position)
* CFrame.Angles(0, math.rad(180), 0)
local modelMode = true
local player = game.Players.LocalPlayer
local mouse = player:GetMouse() --Getting the player's mouse
mouse.Move:connect(function() --When the mouse moves
local mousetarget = mouse.Target
if not modelMode then return
elseif mousetarget:IsA("Frame") and mousetarget.Name == "Left" then
camera.CoordinateFrame = CFrame.new(target.Position)
* CFrame.Angles(0, math.rad(-10), 0)
elseif mousetarget:IsA("Frame") and mousetarget.Name == "Right" then
camera.CoordinateFrame = CFrame.new(target.Position)
* CFrame.Angles(0, math.rad(-10), 0)
end end)
end
end

1 comment
also, I'd like to know how to set a max on how far you can turn left or right!