I have a game stuck if first person, but I want you to be able to press c to toggle mouse free roaming or being stuck to the middle of the screen (Wouldn't be picky if you have to hold C instead of press C).
So here's the script that makes it free roam:
local plrGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local screenGui = Instance.new("ScreenGui", plrGui)
local txtButton = Instance.new("TextButton")
txtButton.BackgroundTransparency = 1
txtButton.Size = UDim2.new(0, 0, 0, 0)
txtButton.Modal = true
txtButton.Parent = screenGui
The problem is that I can't figure out how to make it work only when C is pressed. I tried making a second script that disables it when C isn't pressed but it didn't appear to work.
I think the solution might be toggling if txtButton.Modal is equal to true or false, but I don't exactly know how to go about doing that.
Thanks for reading.

2 comments
ill try that out, thanks!
I got it to work by watching this tutorial, recommend it for anyone having a problem close to mine. Thanks!