Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with chat?

Asked by 10 years ago

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?

1 answer

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
10 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.

game.Players.PlayerAdded:connect(function(playerr) --Starts a PlayerAdded, "playerr" being the player who entered.
wait(.001) --Once again, OCD. Don't really need this.
playerr.Chatted:connect(chat) --Fires the function "chat" that we created at the beginning of the script.
end) --Ends the PlayerAdded function.

:)

Ad

Answer this question