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

Why does my script print out 'Error occurred, no output from Lua.'?

Asked by
awfulszn 394 Moderation Voter
6 years ago

I have a ChatFilter script that kicks players whenever they say a certain word in the blacklist. Although, this is not the case. Whenever a player joins the game, before they even speak, this error is printed to the output: 'Error occurred, no output from Lua'.

I am not sure what this means, as I have never heard of or even experienced this before. The error occurs on line 7.

local Players = game:GetService("Players")

local blacklist = {
    "the code is", "code", "alpha";
}

Players.PlayerChatted:Connect(function(messageType, player, message)
    for _, blocked in next, blacklist do
        if string.match(message, blocked) then
           player:Kick("[ChatFilter] You have said a word or phrase that has caused you to be kicked. You may rejoin.")
            print("[Kick]"..player.Name.." has been kicked by [ChatFilter].")
        end
    end
end)
0
If you are playing it on voidacity's script builder Or another script builder, Sometimes it dont allows you to Do lua scripts, I don't know what to say, just saying this. PaintfulfreeMLG 0 — 6y

1 answer

Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago

.PlayerChatted isn't a method of Players Service.

Note: This is a method, but this can't be used in scripts, only in the command bar

Use .Chatted of players.

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)

    end)
end)

As for the blacklist, you pretty much have it right. I'd just use find, though, tbh.

local blacklist = {
    "the code is";
    "code";
    "alpha";
}

local function isMsgAllowed(msg) -- functions make things nice (break code into chunks)
    msg = msg:lower() -- make it lowercase
    for _,blocked in next, blacklist do
        if(msg:find(blocked))then
            return false
        end
    end
    return true
end

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if(not isMsgAllowed(msg))then
            plr:Kick("MSG")
        end
    end)
end)
0
I forgot about that. Aha. Thanks. awfulszn 394 — 6y
0
Isn't a method. |Sentence Afterwards| It's a method. CootKitty 311 — 6y
0
@CootKitty, may I suggest an improvement? Perhaps you could make it check if it was a letter or two off aswell, that way players couldn't substitute in symbols or the like and bypass the filter. MedievalBeast4 4 — 6y
Ad

Answer this question