I need this because am trying to make mouth movement whenever a player chats
local function GetStringWordsAmount(Text : string)
return #string.split(Text," ")
end
1 Like
thanks so much okay I will try that
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(msg)
local words = 0
local split = msg:split(" ")
for i = 1,#split do
if split[i]:len() > 1 then
words += 1
end
end
print(words)
end)
end)
OR
You can use what @kalabgs wrote above, both ways work.
local function GetStringWordsAmount(Text : string)
return #string.split(Text," ")
end
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(msg)
print(GetStringWordsAmount(msg))
end)
end)
2 Likes