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

i am trying to make a sniper when i zoom in its not stable how do i fix?

Asked by 5 years ago

zoom script model that i Made : https://www.roblox.com/catalog/02521288629/redirect

script.Parent.Equipped:Connect(function()
    local plr = game.Players.LocalPlayer
    local mouse = plr:GetMouse()
    local char = game.Players.LocalPlayer.Character
    local zomm = true
    local cam = game.Workspace.CurrentCamera
 mouse.Button2Down:Connect(function()

while zomm == true do
    wait()
    cam.CameraType = Enum.CameraType.Scriptable
    cam.CFrame = script.Parent.zoomin.CFrame
end
end)
     mouse.Button2Up:Connect(function()
        zomm = false
        cam.CameraType = Enum.CameraType.Custom
        wait(2)
        zomm = true

    end)

end)

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

your setting the camera's CFrame (coordinate frame) and using a loop using wait() as a yield

A simpler way to do it is setting the camera subject to zoomin, and lock the player's camera to FirstPerson mode

Script would look like this:

script.Parent.Equipped:Connect(function()
    local plr = game.Players.LocalPlayer
    local mouse = plr:GetMouse()
    local char = game.Players.LocalPlayer.Character
    local zomm = true
    local cam = game.Workspace.CurrentCamera
    mouse.Button2Down:Connect(function()
        if zoom then
            cam.CameraSubject = script.Parent.zoomin -- sets camera subject to the scope
            plr.CameraMode = Enum.CameraMode.LockFirstPerson -- sets player’s camera to first person
        end
    end)
    mouse.Button2Up:Connect(function()
        zomm = false
        cam.CameraSubject = char:FindFirstChildOfClass(“Humanoid”) -- or change to your humanoid’s name
        plr.CameraMode = Enum.CameraMode.Classic -- makes player able to go into third person
        wait(2)
        zomm = true
    end)
end)

tell me if it worked or not!

0
you could also lower the FOV of the camera, but that might not be the effect you want turtle2004 167 — 5y
0
it work but when i move it washables helleric -3 — 5y
0
washables? the8bitdude11 358 — 5y
Ad

Answer this question