Hello!
I know the trend has already passed(Most likely), but I was bored and decided to make this.
This is just the basics.
This will only show you how to make it so you have limited words. And when you run out, you are kicked.
With that being said . . .
LETS GET STARTED!
SETTING IT UP!
First things first, we need a script to do all this code right? So lets begin by setting up the player!
First we need to have the value of how many words they have left!
We are going to put the value into a folder, which will be leaderstats, that way we can see the words we have left!
Lets get started:
Put this into ServerScriptService. Call it whatever you want! Me personally, I’m going to call it
“Word Handler”
First lets set some variables, such as services and the default value.
local players = game:GetService('Players')
local defaultWords = 150
Next we have to put a folder into the player, then put the value in there. We do this all when the player joins!
local players = game:GetService('Players')
local defaultWords = 150
players.PlayerAdded:Connect(function(player)
-- make the folder
local leaderstats = Instance.new('Folder')
leaderstats.Name = 'leaderstats'
leaderstats.Parent = player
-- make the value
local value = Instance.new('NumberValue')
value.Name = 'Words Left'
value.Value = defaultWords -- set the default amount of words
value.Parent = leaderstats
end)
Next we need t make it so when they talk, it removes words depending on how many they say.
So first lets tell when they talk:
players.PlayerAdded:Connect(function(player)
-- make the folder
local leaderstats = Instance.new('Folder')
leaderstats.Name = 'leaderstats'
leaderstats.Parent = player
-- make the value
local value = Instance.new('NumberValue')
value.Name = 'Words Left'
value.Value = defaultWords -- set the default amount of words
value.Parent = leaderstats
player.Chatted:Connect(function(msg) -- MSG defines the Message. Which is what they said in the chat
-- this runs when they chat! WOOP WOOP
end)
end)
Now we have to:
- Split up the message so we can get all the words
- take away a word depending on the total amounts of words.
- kick them if they run out of them.
So here we go!
First lets split up the message
player.Chatted:Connect(function(msg) -- MSG defines the Message. Which is what they said in the chat
local splitMessage = string.split(msg,' ') -- this will split the message everytime there is a space in what they say
end)
I could make this so when they say other things like _ or - that counts as a new word but Im lazy.
Next lets explode!
JK
Next lets find out how many words to remove
player.Chatted:Connect(function(msg) -- MSG defines the Message. Which is what they said in the chat
local splitMessage = string.split(msg,' ') -- this will split the message everytime there is a space in what they say
local words = #splitMessage -- the amount to remove
end)
Next lets remove the words!
and then tell if it is equal to or less than 0. if so kick them
player.Chatted:Connect(function(msg) -- MSG defines the Message. Which is what they said in the chat
local splitMessage = string.split(msg,' ') -- this will split the message everytime there is a space in what they say
local words = #splitMessage
value.Value -= words
if value.Value <= 0 then
player:Kick('Ran out of letters!')
end
end)
And thats how you do it! Simple as that!
I tested this, it works!