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

LockFirstPerson is not working for some reason?

Asked by 4 years ago

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.

01local InRound = game.ReplicatedStorage.InRound
02local Plr = game.Players.LocalPlayer
03 
04 
05if InRound.Value == true then
06 
07    Plr.CameraMode = Enum.CameraMode.LockFirstPerson
08end
09 
10if InRound.Value == false then
11    Plr.CameraMode = Enum.CameraMode.Classic
12end

1 answer

Log in to vote
0
Answered by 4 years ago

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:

01local InRound = game.ReplicatedStorage.InRound
02local Plr = game.Players.LocalPlayer
03 
04InRound:GetPropertyChangedSignal("Value"):Connect(function()
05if InRound.Value == true then
06    Plr.CameraMode = Enum.CameraMode.LockFirstPerson
07elseif InRound.Value == false then
08    Plr.CameraMode = Enum.CameraMode.Classic
09end
10end)

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

0
Thanks! TheStarRblx 27 — 4y
0
No problem. Don’t forget to accept the answer if it works CreationNation1 459 — 4y
0
ok! TheStarRblx 27 — 4y
Ad

Answer this question