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

How do I make a Chat function?

So what I'm needing is, When someone says a word, something happens. Its hard to explain, here is my script at the moment.

Players.PlayerAdded:connect(function(Player)
	Player.Chatted:connect(function(Message)
		if Message == ("Lumos") then
			script.Parent.Handle.ParticlePart.Lumos.Enabled = true
		end
	end)
end)

I've tested with other things but I'm just not able to make this work.

(The script is in a Gear, the gear has a handle and in the is the mesh and particlepart, inside particlepart is a particle emitter. The gear is also in starter pack)

1 comment

0

You may prefer to use Lua string patterns instead. Instead of Message == ("Lumos") you could try Message:match(".Lumos.") so that the player can say Lumos wherever in the sentence.

2 answers

What you needed to do was to check if the player has equipped the tool and then initiate the chat function.

tool = script.Parent
particle = tool.Handle.ParticlePart.Lumos
player = game.Players.LocalPlayer
tool.Equipped:connect(function()
print('Enter')
player.Chatted:connect(function(msg)
	if string.lower(msg) == 'lumos' then
		print('Works')
		particle.Enabled = true
	end
end)

end)

This is how i use player chatted functions just tweak it a little and it'll work.

game.Players.PlayerAdded:connect(function(plr)
	plr.Chatted:connect(function(Msg)
local msg = Msg:lower()
 if string.sub(msg, 1, 13) == "Lumos" then
 wait(0.1)
print("hi")
---------//do what you want here\\--------------
---------//you might need to add another end depending on what you write\\--------------
		end
	end)
end)

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