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

How would I make it so only certain players (username specified) can access a chat channel?

Hi, I'm making a game and would like to make an Admin Chat of sorts (or as I've called it Exclusive Chat). I can't figure out how to do this. I've made the channel non-joinable with the /join command, and also private, so it behaves like team chat and whisper. However, I am struggling to actually make the channel accessible to the users I specify. Please help!

My initial idea was something like this

local function Run(ChatService)
local players{"iBallisticEDB","giangamerino"}

if player.Name == players then

ChatSpeaker:JoinChannel()

but I don't know whether this would actually work, as I've had no luck.

2 answers

You got it correct although your iteration of the array is incorrect. Here is what you should be aiming for.

local players{"iBallisticEDB","giangamerino"}

for _, v in pairs(players) do
    if player.Name == v then
        --true
    else
        --false
    end
end

Here's the for pairs loop documentation in lua https://www.lua.org/pil/7.3.html

There are also other ways to achieve this, but this is the most common method people would use.

1 comment

0

upvoted

Your current syntax has some issues, your missing an end after line 6 for the if, and then one after that for the function. Inside () should be an string with the channel name. Your also looping checking thru the array incurrently. If you need help with making channels, considering looking for that in Roblox's detailed lua chat system article.

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