So what I'm trying to do is using a Third Person shoulder camera script, the player will be able to play the shooter game in third person. And the aiming is when you hold down the right mouse button, the FOV would zoom in to say 30 and when you release, it'll return back to 70. I've written something up but it doesn't seem to be doing to job. Please help me fix it.
wait(.75)
plr = game.Players.LocalPlayer
repeat wait() until plr.Character
char = plr.Character
c = workspace.CurrentCamera
hrp = char.HumanoidRootPart
m = plr:GetMouse()
x = 0
y = 0
--camera
c.CameraType = "Scriptable"
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
function mouse(name, state, inputObject)
x = x + (-inputObject.Delta.x/250)
y = y + (-inputObject.Delta.y/250)
if y > 1.5 then
y = 1.5
elseif y < -1.5 then
y = -1.5
end
end
game:GetService("ContextActionService"):BindActionToInputTypes("MouseMove", mouse, false, Enum.UserInputType.MouseMovement)
while true do
game["Run Service"].RenderStepped:wait()
hrp.CFrame = CFrame.new(hrp.Position) * CFrame.Angles(0,x,0)
c.CoordinateFrame = char.Head.CFrame * CFrame.Angles(0,0,0) * CFrame.new(1.5,0,5)
char.Torso.Neck.C0 = CFrame.new(0,1,0) * CFrame.Angles(y + 1.55,3.15,0)
end
function RDown(RD)
if Button2Down == true then
c.FieldOfView = 40
else if Button2Down == false then
c.FieldOfView = 70
end
end
end
local player = game.Players.LocalPlayer
player.MouseButton2Down:connect(RDown)

2 comments
It needs to be a LocalScript.
It is.