How do you toggle Modals in a first-person game in a GUI?
Asked by
5 years ago Edited 5 years ago
I don't know if this is an issue or just my own unawareness. I'm trying to make my place first-person locked, but when you open up the GUI, Modal is set to True in the button, thus letting you move your mouse around as long as the GUI is still up. The problem is that when the "X" button is pressed and the GUI collapses by setting Modal to false, you can still move your mouse around freely. Am I doing something wrong? Incorrect syntax?
I have two TextButtons, alongside some TextLabels and other whatnot. One is to bring up the GUI, and the other appears on it itself.
LocalScript inside button to bring the GUI up. This is in a separate TextButton (Button), inside a different frame (Sidebar), inside the same ScreenGui (Menu), in StarterGui.
01 | local ShopThing = script.Parent.Parent.Parent:WaitForChild( "ShopThing" ) |
02 | local Tween = game:GetService( "TweenService" ) |
05 | game:GetService( "UserInputService" ).InputBegan:connect( function (input) |
06 | if input.KeyCode = = Enum.KeyCode.L then |
08 | Tween:Create(ShopThing,TweenInfo.new( 1 ,Enum.EasingStyle.Back,Enum.EasingDirection.Out, 0 , false , 0 ), { Position = UDim 2. new( 0.5 , 1 , 0 , 10 ) } ):Play() |
09 | game.Lighting.Blur.Size = 15 |
10 | script.Parent.Modal = true |
The "X" button to close the GUI. This is a LocalScript inside a different TextButton (Exit Button), inside a frame (ShopThing), inside a ScreenGui (Menu), in StarterGui.
01 | local ShopThing = script.Parent.Parent.Parent:WaitForChild( "ShopThing" ) |
02 | local Tween = game:GetService( "TweenService" ) |
03 | local StarterGui = game:GetService( "StarterGui" ) |
06 | script.Parent.MouseButton 1 Click:Connect( function () |
07 | Tween:Create(ShopThing,TweenInfo.new( 1 ,Enum.EasingStyle.Back,Enum.EasingDirection.Out, 0 , false , 0 ), { Position = UDim 2. new( 0.5 , 1 ,- 0.15 , 10 ) } ):Play() |
08 | game.Lighting.Blur.Size = 3 |
10 | game.StarterGui.Menu.Sidebar.Button.Modal = false |
Any help would be much appreciated!
Game Link: https://www.roblox.com/games/4753954002/Alley-oop?refPageId=c74eb7df-44bb-45a6-9326-fe9d35a22558