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

LockFirstPerson is not working for some reason?

I'm trying to make a round based game where it teleports players to the round and back. When they are in the round it should turn them to first person (using LockFirstPerson), but it doesn't work or print any errors in the output? I also used the print method to find out the code where the error starts, and it didn't print anything.

(InRound is a bool value that changes when the player enters the round)

This is also a local script. I tried it out as a server script as well and it still didn't work.

local InRound = game.ReplicatedStorage.InRound
local Plr = game.Players.LocalPlayer


if InRound.Value == true then
	
	Plr.CameraMode = Enum.CameraMode.LockFirstPerson
end

if InRound.Value == false then
	Plr.CameraMode = Enum.CameraMode.Classic
end

1 answer

The reason it wouldn’t work is because the function isn’t always running, it only occurs as soon as they join the game. Here is a script to help you out:


local InRound = game.ReplicatedStorage.InRound
local Plr = game.Players.LocalPlayer

InRound:GetPropertyChangedSignal("Value"):Connect(function()
if InRound.Value == true then
    Plr.CameraMode = Enum.CameraMode.LockFirstPerson
elseif InRound.Value == false then
    Plr.CameraMode = Enum.CameraMode.Classic
end
end)

Sorry about the formatting, I typed it on mobile but it should still work.

3 comments

0

Thanks!

0

No problem. Don’t forget to accept the answer if it works

0

ok!

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