Hey there!
I’ll keep it clear and simple, how would I detect how much words a player chatted, I’m making an animated face system and every word will make the mouth open.
Hey there!
I’ll keep it clear and simple, how would I detect how much words a player chatted, I’m making an animated face system and every word will make the mouth open.
Just run a .Chatted
event and split the text with every space they make
Example
local plrs = game:GetService("Players")
plrs.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local words = msg:split(" ") --Splits words from space bar
print(#words)
end)
end)
With this, if you wrote “Hi my name is Embat”, it would print out 5, since it splits the words. You can tinker with this to make it work how you want, but that’s generally how to detect the amount of words written, you may need to do some word checking before doing the face animations
Interesting, how would I make a function run the amount of words? Like make the face talk 5 times
You just use a for
loop starting from 0 till the length of the words table
local plrs = game:GetService("Players")
plrs.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local words = msg:split(" ") --Splits words from space bar
for i = 0, #words do
--Code
end
end)
end)
You probably have at least the system for the face aniamtions, so just do what I did when a player chats
-- Script removed so nobody steals
it doesn’t seem to work for some reason… doesn’t print anything either
It’s because the while
loop is in the way, put the event above it or coroutine the loop
so i put the blink stuff under the talk stuff?
Correct, because anything under a while loop will not be ran unless the loop ends
it works, tysm
I’ll go work on the rest for now
Anytime! If you hae anymore issues don’t be afraid to make another post!
I will probably make a post after this on how to make a “text to speech” thing lol, I’ve seen a lot of posts about it but none have a solution