#ServerScriptService help (chat to function something)
1 messages · Page 1 of 1 (latest)
first require a module (for example inside the script itself)
local blacklist = require(script.Blacklist)
the modulescript will be something like:
return { -- list of all userIds
101010101010,
202309203910,
}
then in the script:
...
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg, plr)
-- aaand to be honest i don't remember how can you "cancel" the event, try looking on the docs or asking chatgpt maybe?
end)
end)
but you gotta check like:
for _, id in ipairs(blacklist) do
if id == player.UserId then ... cancel the event ... end
end
Good idea
np
if you're making a mute system there are a ton in roblox dev forum, toolbox or youtube videos
oh wait but couln't you store the index so you don't need to loop through every element in the module?
for example
player.UserId = player.UserId
}```
and
if table[player.UserId] then return end
would make the process faster too since it's a hash table
hmm no clue about the performance, but great idea
it's a instant grab since it's fully open to memory
ofc takes a bit more memory to store it all since a array gets stored as a refrence to the next element
but this would generally be better for performance if you wanted to blacklist multiple players at one time
imagine looping through a array with a million elements
it's gonna take forever
like imagine you have a million players looping through a array with a million elements
million x million = trillion operations
but a hash table it's instant access since it's open to the mem
oh i see