Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why is the localplayer's camera not able to change properties?

Asked by
wookey12 174
6 years ago

the script pretty much says it all, if you right click, either zoom in or out. it's not working for some reason

mouse.Button2Down:Connect(function()
if aiming == false then
    aiming = true
    workspace.CurrentCamera.FieldOfView = 40
end
if aiming == true then
    aiming = false
    workspace.CurrentCamera.FieldOfView = 70
end
end)
0
no errors wookey12 174 — 6y

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Hello, wookey12!

your scipt was setting the variable 'aiming' to true, tests it and sets it to false, so you have to use a elseif!

Working script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local aiming = false
mouse.Button2Down:Connect(function()
    if aiming == false then
        aiming = true
        game.Workspace.CurrentCamera.FieldOfView = 40
    elseif aiming == true then
        aiming = false
        game.Workspace.CurrentCamera.FieldOfView = 70
    end
end)

Good Luck with your games!

Ad

Answer this question