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

How do I make my GUI appear using a command?

I want to build a custom command that makes a GUI pop up. I have everything, but I don't know how to make my GUI pop up with a command. I have already tested my script and confirmed that whenever the player says the command, it will execute whatever I want it to. How do I make it so that it will make my GUI appear whenever someone says that command?

1 comment

0

Is this done using a LocalScript or a ServerScript?

3 answers

✓ Accepted answer
local players = game:GetService("Players")

players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if msg == "CMD" then
		game.StarterGui.NAMEOFSCREENGUIHERE.Enabled = true
        end
    end)
end)

Change "CMD" to the command you want and change "NAMEOFSCREENGUIHERE" to the name of your ScreenGui.

Let me know if there is any issues.

game.Players.PlayerAdded:connect(
    function(player)
        local gui = player.PlayerGui.ScreenGui
        local command = "!opengui"
        player.Chatted:connect(
            function(msg)
                local msg = string.lower(msg)

                if msg == command then
                    gui.Enabled = true
                end
            end
        )
    end
)

Hi there. What you can do, is this:

You would make sure your script is a child of the ScreenGui, which means, just make sure that the script is inside your ScreenGui,

Code:

local GUI = script.Parent --reference variable for the GUI
GUI.Enabled = false --sets the GUI enabled to false, for now,

game.Players.PlayerAdded:Connect(function(Player) --event for when a player joins the game, and assigns "Player", to the player who joined.
	Player.Chatted:Connect(function(ChattedMessage) --Event for when the player who joined chatted, and sets that assigns the chatted message to "ChattedMessage"
		if ChattedMessage == "Command" then --if statement for if the chattedmessage is equal to "Command", then
			GUI.Enabled = true --enable the gui, so we can see it
		end
	end)
end)

This script should work, and make sure you understand it. Note that you should change change "Command", to whatever you want your command to be.

Hopefully I helped, and have a great day!

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