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.

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

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:


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.

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