Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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 comment

1

Next time, don't just post code. Others may not be able to understand your code and will not learn from it.

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)

1 comment

0

What's this?

This discussion is preserved as it was. New answers, comments, and votes are closed.