Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you disable chat for a player who has said a bad word?

I'm working on my big game and merely helped me with a script that could disable chat. (in his free models). I don't want to kick them, because if they typed the wrong key or didn't read the rules, they would be mad, then they will never come again. Here is merely's script:

--Configuration
local muteAt = 6 --if the player chats 7 times in timePeriod, he will get muted
local muteDuration = 20 -- length that muting lasts
local timePeriod = 10

--exploiters can delete it if it's in Workspace
if script.Parent == workspace then 
	script.Parent = game:GetService("ServerScriptService")
end

local Players = game:GetService("Players")
local chatBucket = {}

function mute(player)
	local character = player.Character
	if character and not character:FindFirstChild("FloodcheckWarning") then
		local warning = script:FindFirstChild("FloodcheckWarning"):Clone()
		warning.Name = tostring(muteDuration)
		warning.Disabled = false
		warning.Parent = character
	end
end

function onChatted(player)
	local chats = (chatBucket[player] or 0) + 1
	if (chats > muteAt) then
		mute(player)
	end
	chatBucket[player] = chats
end

function onPlayerAdded(player)
	player.Chatted:connect(function(msg)
		onChatted(player)
	end)
end

Players.PlayerAdded:connect(onPlayerAdded)

while wait(timePeriod) do
	chatBucket = {}
end

then he has a localscript as a child,

local StarterGui = game:GetService("StarterGui")
local player = game:GetService("Players").LocalPlayer
local muteLength = tonumber(script.Name)

local gui = script:WaitForChild("Gui")
gui.Parent = player.PlayerGui

StarterGui:SetCoreGuiEnabled('Chat',false)
wait(muteLength)
StarterGui:SetCoreGuiEnabled('Chat',true)

gui:Destroy()
script:Destroy()

after that he has a gui and a text label. I'm wondering how i can turn this into a word sensor instead.

Thanks for reading!

Note: I am not asking for the whole script but like a few parts. I do know about tables and stuff.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.