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 make it so that if you say something, something else happens?

So, for my group I want you to say something like ";load map Bricktops" something like that at least. I had the idea of making it so you place an if function saying if the player sais that then then transparency = 0, and cancollide = false. How do I have it monitor what a player says?

2 answers

Hi there.

It'd be useful to look at ROBLOX's official "cheap" admin command guide.

You'd want to use string:sub()

Here's some pre-made code I put together from this, just make your map and put it in a folder named Maps in Lighting. Then add your group admins, and the command is ;loadmap [as it is named in Lighting.]

local isAdmin = {["DeltaDominus"] = true, ["Player1"] = true, ["Player2"] = true} -- admins
 
function loadMap(map)
    game.Lighting["Maps"]:WaitForChild(map):Clone().Parent = game.Workspace
end
 
function onChatted(message, player)
    if message:sub(1, 7) == ";loadmap " and isAdmin[player.Name] then
        local map = loadMap(message:sub(6))
       end
end
 
 
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

Any issues, DM me on ROBLOX or Discord [see profile]

Attach the "Chatted" event to the player. It returns a parameter which is what the player has chatted in string value. For example, if you want the event attached when the player enters it would look something like this:

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(PlayerChatted)
end)

From then on you can create a function that dictates what you want to do with that chat.

function PlayerChatted(Message)
	if Message == ";load map BrickTops" then
		--Does stuff.
	end
end

1 comment

0

Great, but making a dynamic "command" so you could load maps in this case and not have to write another command for each map would be better as I have put.

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