I’m on a Roblox dev camp and want to lock the player’s camera in first-person mode when they enter a certain area.
I put in a part with CanCollide turned off and a local script inside the part that, when touched, should set the player’s CameraMode to LockFirstPerson, however when testing it I found out the script wouldn’t start at all.
I tried moving the script into ServerScriptService and coding it so that it’d find the part from there, but it didn’t work either.
The code is as follows:
local playerService = game:GetService("Players")
local player = playerService.LocalPlayer
script.Parent.Touched:Connect(function()
player.CameraMode = Enum.CameraMode.LockFirstPerson
end)
okay, make a LocalScript in StarterGui or in StarterPlayerScripts and paste the following script
local players = game:GetService("Players")
local player = players.LocalPlayer
local part = workspace.Part
part.Touched:Connect(function(Touch)
local playerTouching = players:GetPlayerFromCharacter(Touch.Parent)
if playerTouching then
if playerTouching == player then
player.CameraMode = Enum.CameraMode.LockFirstPerson
end
end
end)