Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you toggle Modals in a first-person game in a GUI?

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.

local ShopThing = script.Parent.Parent.Parent:WaitForChild("ShopThing")
local Tween = game:GetService("TweenService")

		
game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.L then
        -- Do something when L is pressed
Tween:Create(ShopThing,TweenInfo.new(1,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0),{Position = UDim2.new(0.5,1,0,10)}):Play()
game.Lighting.Blur.Size = 15
script.Parent.Modal = true
    end
end)

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.

local ShopThing = script.Parent.Parent.Parent:WaitForChild("ShopThing")
local Tween = game:GetService("TweenService")
local StarterGui = game:GetService("StarterGui")


script.Parent.MouseButton1Click:Connect(function()
Tween:Create(ShopThing,TweenInfo.new(1,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0),{Position = UDim2.new(0.5,1,-0.15,10)}):Play()
game.Lighting.Blur.Size = 3
print("bruv")
game.StarterGui.Menu.Sidebar.Button.Modal = false
end)

Any help would be much appreciated!

Game Link: https://www.roblox.com/games/4753954002/Alley-oop?refPageId=c74eb7df-44bb-45a6-9326-fe9d35a22558

5 comments

2

PlayerGui.. not StarterGui...

0

so it would work if I moved this to PlayerGui?

0

Yes, I apologize if I come off a bit angry. This is too common of a mistake made within this forum, and I’ve responded with the same answer numerous times, you can understand it gets tedious after a while

0

I don't got a clue how or why that worked, but you're a lifesaver. Thank you.

1 answer

hello, i played your game and i think you found out how to do it. i want to do the same because my games first person but when I'm in a gui i want the mouse to move, I would appreciate it if you could help

This discussion is preserved as it was. New answers, comments, and votes are closed.