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 fire an event when a player says a specific word?

Hello, I would like to make a funny video on 100 ways to die in ROBLOX I would like to make a quick Admin Command sort of thing.

game.Players.PlayerAdded:Connect(function(player)
  player.Chatted:Connect(function(msg)
        local water = game.Workspace.WATER
        water.Position = -5.4, 13.921, 1.74
        water.Size = 517.92, 42.15, 512.92
  end)
end)

I want to make it so if the players says "Water!" The water rises killing them. If anyone could help it would be highly appreciated and they will be shouted out in the video!

Thank you, Aidan.

2 comments

0

I think you looking for “if msg:lower() == "!command" then”.

0

Of course “!command” could be anything, but depending on what your trying to do, you may want to make a custom function first. As well as taking into consideration if other players are calling the function at the same time or repeatedly etc.

1 answer

All you have to do is match the msg to your string. In your case, it's really easy, since there's no variation.

You can do

if msg == 'Water!' then 

You also need to make your Position and Size a Vector

water.Position = Vector3.new(-5.4, 13.921, 1.74)
water.Size = Vector3.new(517.92, 42.15, 512.92)

All together now

local mystring = "Water!"
local water = workspace:WaitForChild('WATER')

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if msg:lower() == mystring:lower() then 
			-- if you want it to be exact with caps
				-- omit the :lower() method
			water.Position = Vector3.new(-5.4, 13.921, 1.74)
			water.Size = Vector3.new(517.92, 42.15, 512.92)
		end
	end)
end)

2 comments

0

Hello, this has not been working for me. I even tried changing workspace to game.Workspace. Thank you for trying to help me though! :)

0

What's the output say? Debug my guy.

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