I’ll try, but I actually just noticed what the problem is.
In your code, you create a boolean (true or false) variable named GuiOpen, which you use to check if any dialogs are on-screen. Later in the script, you try setting its “Modal” property. Modal doesn’t exist on variables, though.
So, basically, what I was saying was that “Modal” is a property that only can be used with button Gui objects like TextButtons.
If you check the checkbox shown here, “Modal”, your game will do what you’d like it to do without having to use that script to set the Modal property.
In this video, I show that the mouse cursor is only able to be freely moved around when the dialog appears. When it closes, the mouse controls looking around again.
This was done by just checking the “Modal” property’s checkbox.
Alternative method that I wouldn't recommend
If you’d like to enable Modal with conditions like in your script, you’ll have to reference a button instance. For example, if you have a TextButton placed within Frame within a ScreenGui like this:
…then you would reference it with
game:GetService("Players")[...].ScreenGui.Frame.TextButton.Modal = true
I’d recommend checking the “Modal” property on any buttons in the admin panel then removing the “GuiOpen.Modal” lines from your script; This should give you the results you’re after.
local AdminFrame = script.Parent.AdminFrame
local UIS = game:GetService("UserInputService")
local GuiObject = script.Parent
local GuiOpen = false
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.F then
if not GuiOpen then
GuiOpen = true
if AdminFrame.Visible == true then
AdminFrame.Visible = false
end
else
GuiOpen = false
if AdminFrame.Visible == false then
AdminFrame.Visible = true
end
end
end
end
end)
I hope I didn’t make this second post too complicated. If I did, I hope someone else replies to help out.