You know in some games, if you chat a certain word or phrase, something happens? Yeah I want to learn that. I’m pretty sure you have to use a remote event, but I don’t know. If you have tips or suggestion, please feel free to talk about it.
I’m a beginner scripter. I’m not sure how to add a ChatModule that triggers when a string pattern is recognized
Edit: Ignore previous response, see below
If you want a much simpler approach to this, check this out: Player | Documentation - Roblox Creator Hub
Here is some sample code if you want to try an easier way:
game.Players.PlayerAdded:Connect(function(player) -- runs every time a player joins
player.Chatted:Connect(function(msg) -- runs once the player that joined chats a message
if msg == "hi" then -- create your conditions
-- do stuff here if the condition is met
end
end)
end)
So I am doing like an animation, if you type a certain word in, where would you put the animation?
This seems like a bad and an over-complicated example, especially for such a simple and a beginners question.
For @Kamlkaze_Kid, you can use the Chatted event as he mentioned. To play an animation, you’d first need to get the character’s humanoid, load the animation in and play.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local anim = character:WaitForChild("Humanoid"):LoadAnimation(animation)
player.Chatted:Connect(function(message)
if message == "keywordhere" then
anim:Play()
end
end)
end)
end)
You’re absolutely right, there’s much better ways to approach it
Where would you put the actual animation?
I don’t know if I understand your question properly but I think you mean like chat commands
If you mean this you could use this script as a template for commands
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == "Hello World"then
print("Hello World from "..Player.Name)
end
end)
end)
And it’s working good like what you see in this photo
I’m sorry if that didn’t help
What I meant was where would I put the actual animation thing. (ex: serverstorage, replicatedstorage)
The animation goes where you want usually under the script which should be a local script.
This may help you:
That’s totally up to you, you can make it neat and put it inside a folder in ReplicatedStorage or you can even put the animation inside the script itself. As long as it’s a place where the script can reach.
For example: the server can’t access the player’s PlayerGui,
the client can’t access ServerStorage,
et cetera.
Are you trying to run an animation on the player?
If so, you can just create a new one with Instance.new, and set all of its properties.