Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
-3
Answered by 10 years ago

you could just kick him on chatted

0
thats what I said i don't want to do. TroytheDestroyer 75 — 10y
0
Oh Ok Sorry Timster111 25 — 10y
Ad

Answer this question