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

You know how in some games 1st person is locked?

Asked by 8 years ago

How would I do that?

In studio I use this script:

repeat wait() until game.Players.LocalPlayer
local p = game.Players.LocalPlayer
p.CameraMode = "LockFirstPerson"

It works perfectly, but in the actual active place it doesn't. I tried putting this code into a local script instead, but then it doesn't work at all: In studio or in the active place. Any help?

1 answer

Log in to vote
0
Answered by 8 years ago

This is not working because you're using a script instead of a LocalScript.

You said that when you put it into a LocalScript it didn't work at all. This is almost certainly because you're putting it it the wrong place.

LocalScripts do not work in Workplace or ServerScriptService. Place a LocalScript with your code in StarterPack or ReplicatedFirst and it should work fine.

When making the change you can get rid of line 1 of your LocalScript. You can do this because when a player gets added, StarterPack and ReplicatedStorage will run the scripts for the player when they join. So we know they exist. There's no need to double check.

The LocalScript will not run until the game replicates the LocalScript to the player.

Good Luck!

Ad

Answer this question