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

Unlockable first person cursor?

Asked by 3 years ago

I'm working on a "horror" game and I want the player to be able to unlock the mouse cursor by pressing LeftControl but remaining in first person as featured in "get a snack at 4am"

https://www.roblox.com/games/6165106805/get-a-snack-at-4-am

I already have my simple first person lock of course:

player = game.Players.LocalPlayer
player.CameraMode = "LockFirstPerson"

But how can I force the player to remain in first person but allow for the cursor to be moved upon pressing LeftControl?

1 answer

Log in to vote
0
Answered by 3 years ago

there's something called Modal in TextButton you can use that by making it invisible and making Modal true.

if you need the code here:

local modal = false

game:GetService("UserInputService").InputBegan:Connect(function(input, typing)

    if typing then return end

    if input.KeyCode == Enum.KeyCode.LeftControl then
        if modal == false then
            modal = true
            TextButton.Modal = true
        else
            modal = false
            TextButton.Modal = false
        end
    end
end)
Ad

Answer this question