ScreenGui preventing me from changing camera to LockFirstPerson

I’m trying to make a FPV game, and I have the default Roblox cursor disabled, and I’m using a ScreenGui with a tiny frame in the center to make my own crosshair. But when I use a script to force First-Person, and the ScreenGui gets cloned from replicated storage to the playerGui folder, it prevents the FPV from happening. Any help? It is kind of frustrating.

script:

local plr = game:GetService('Players').LocalPlayer
local userInputService = game:GetService("UserInputService")
userInputService.MouseIconEnabled = false

plr.CameraMaxZoomDistance = 0.5
plr.CameraMinZoomDistance = 0.5
plr.CameraMode = "LockFirstPerson"
plr.NameDisplayDistance = 25
plr.NameDisplayDistance = 50

wait(0.2)

local RS = game:GetService('ReplicatedStorage')
RS.Ye:Clone().Parent = plr.PlayerGui

Does it work without the screen gui?

Yeah. But as soon as the screenGui gets cloned to the gui folder, it like overwrites it.

I may have to change the cursor icon to my own uploaded image. But I wanted to go with the gui way because it would be cool to have the ability to customize it.

I don’t know if this will fix the problem but it’s already first-person locked if you set the MaxZoomDistance and MinZoomDistance to 0.5 ?

1 Like

I can still zoom in and out. The max & min zoom and the FirstPersonLock gets reverted. I made my way to my player while playing the game, and it changed the max zoom to 128 and minimum zoom to 0.5.

Sometimes the default roblox UI messes things up. Try creating a custom lock first person function

local rs = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
rs.RenderStepped:Connect(function()
     local char = plr.Character
     if char then
          cam.CFrame = char.Head.CFrame
     end
end)
1 Like

I figured out the reason why (I face-palmed pretty hard lol). I made a rookie mistake by placing the scripts inside of “StarterPlayerScripts”, not “StarterCharacterScripts”. It works fine now, but I do need to make the crosshair a little higher (because of the top bar for the menu buttons).