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

How can I lock a Camera in first-person or third-person?

Asked by
Zerio920 285 Moderation Voter
10 years ago

I'm wondering what script would allow me to lock a player's camera into third or first-person mode. I heard that minzoom and maxzoom weren't working, and I haven't had much luck with it either. It would be helpful to have the camera locked a set distance away from the player though. Any ideas?

3 answers

Log in to vote
1
Answered by 10 years ago
game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if plr and char then
            plr.CameraMaxZoomDistance = 0.5
            plr.CameraMinZoomDistance = 0.5
        end
    end)
end)

1
Next time, don't just post code. Others may not be able to understand your code and will not learn from it. Spongocardo 1991 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

game.Players.LocalPlayer.CameraMode = "2"

Log in to vote
0
Answered by 10 years ago
self = script.Parent
c = workspace.CurrentCamera

player = game.Players.LocalPlayer
char = player.Character or player.CharacterAdded:wait()
humanoid = char:WaitForChild("Humanoid")

-- Apply some properties

player.CameraMaxZoomDistance = 0.5
c.FieldOfView = 100 -- Things get trippy if we don't do this.
humanoid.CameraOffset = Vector3.new(0,0,-0.5)

function lock(part)
    if part and part:IsA("BasePart") then
        part.LocalTransparencyModifier = part.Transparency
        part.Changed:connect(function (property)
            part.LocalTransparencyModifier = part.Transparency
        end)
    end
end

for _,v in pairs(char:GetChildren()) do
    lock(v)
end

char.ChildAdded:connect(lock)

c.Changed:connect(function (property)
    if property == "CameraSubject" then
        if c.CameraSubject and c.CameraSubject:IsA("VehicleSeat") and humanoid then
            -- Vehicle seats try to change the camera subject to the seat itself. This isn't what we wan't really.
            c.CameraSubject = humanoid;
        end
    end
end)
0
What's this? Muoshuu 580 — 10y

Answer this question