Hey there! I’m trying to make a game, that kicks you if you use more than one word. Its like “limited words” and whatnot, but you can ONLY say one word at a time. More than one word in your message will kick you, but if you want me to, perhaps I could allow spaces as well, like: “pizza [space]”, but its up to you.
I have had some code (credit to Buzzettego, the creator of the code), but when I say more than one word, it doesn’t kick me…
local SendWordsRE = game.ReplicatedStorage.SendWords
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local head = character:WaitForChild("Head")
local WordsAmountGui = script.WordsAmount:Clone()
local WordsGui = script.WordsGui:Clone()
local oneWordIntValue = Instance.new("IntValue", player)
oneWordIntValue.Name = "WordsAmount"
oneWordIntValue.Value = 1
player.Chatted:Connect(function(message)
local amount = #string.split(message)
if amount >= oneWordIntValue.Value then
player:Kick("You said more than one word!")
end
end)
end)
end)
Any ideas? Yes I am a noob at coding, and yes I am giving credit to this person (for making the script) and of course, whoever helps me. Heck, I might credit everyone who is helpful to me, but your choice
Right here I believe is where the issue lies, you run string.split() and provide the message but you never say what it should split, I believe putting a ," " after the message variable in the string.split should fix it.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local head = character:WaitForChild("Head")
player.Chatted:Connect(function(message)
local amount = #string.split(message," ")
if amount > 1 then
player:Kick("You said more than one word!")
end
end)
end)
end)
I got this code so far, but nothing seems to be working…