0

# Help with chat?

So I've been thinking of a msg:lower() like script, so if you say "MainMenu/", it will make a GUI pop up, but only for your PlayerGUI, how would you do this?

0
Discern 1007
7 years ago

You would fire anfunction with the Chatted event for when a player chats. Then, you would use an if statement to see if their chat is what you want. If it is, then you put in the code. You would connect the function to a PlayerAdded, making it correlate to every player. The GUI would need to be in Lighting.

So lets say the GUI's name is "MainMenuGui" (Without the quotation marks, obviously).

Here is what would work:

function chat(msg, player) --The function's name is "chat". What they actually say is "msg". The player who is chatting is "player."
wait(.001) --I do this for OCD. It's not really needed.
if string.lower(msg) == "mainmenu/" then --Making sure the string is lower cased, since we are transforming all the characters in the actual message to lower case.
game.Lighting.MainMenuGui:Clone().Parent = player.PlayerGui --Cloning the Main Menu Gui to the player's PlayerGui.
end --Ends the if statement.
end --Ends the function.