Im making this scrambler script but I want it to be able to be toggled so it checks if a value is true or false but its making an error when i do that.
Script:
local functionId = "editText"
local function doFilter(speaker, messageObject, channelName)
local random = Random.new()
local letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
--function getRandomString(length, includeCapitals)
-- local length = length or 10
-- local str = ''
-- for i=1,length do
-- local randomLetter = letters[random:NextInteger(1,#letters)]
-- if includeCapitals and random:NextNumber() > .5 then
-- randomLetter = string.upper(randomLetter)
-- end
-- str = str .. randomLetter
-- end
-- return str
--end
local DTValue = speaker.Backpack.DTValue -- error.
if DTValue.Value == true then
print("Player and DT True")
local length = string.len(messageObject.Message)
local str = ''
for i=1,length do
local randomLetter = letters[random:NextInteger(1,#letters)]
if random:NextNumber() > .5 then
randomLetter = string.upper(randomLetter)
end
str = str .. randomLetter
end
messageObject.Message = str
end
end
local function runChatModule(ChatService)
ChatService:RegisterFilterMessageFunction(functionId, doFilter)
end
return runChatModule
Error:
DoMessageFilter Function 'editText' failed for reason: Chat.ChatModules.DTScript:20: attempt to index nil with 'DTValue' - Server - ChatService:396
The speaker is not nil for some reason i did speaker.Name which is nil so its just giving the same error. It cannot find the value its not the DTValue.Value == true.
▶ DoMessageFilter Function 'editText' failed for reason: Argument 1 missing or nil (x2) - Server - ChatService:396
Before when I commented out the value stuff it worked. Now its not.
local functionId = "editText"
local function doFilter(speaker, messageObject, channelName)
local random = Random.new()
local letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
--function getRandomString(length, includeCapitals)
-- local length = length or 10
-- local str = ''
-- for i=1,length do
-- local randomLetter = letters[random:NextInteger(1,#letters)]
-- if includeCapitals and random:NextNumber() > .5 then
-- randomLetter = string.upper(randomLetter)
-- end
-- str = str .. randomLetter
-- end
-- return str
--end
local speaker = game:GetService("Players"):FindFirstChild(speaker.Name)
local DTValue = speaker:WaitForChild("Backpack").DTValue
if DTValue.Value == true then
print("Player and DT True")
local length = string.len(messageObject.Message)
local str = ''
for i=1,length do
local randomLetter = letters[random:NextInteger(1,#letters)]
if random:NextNumber() > .5 then
randomLetter = string.upper(randomLetter)
end
str = str .. randomLetter
end
messageObject.Message = str
end
end
local function runChatModule(ChatService)
ChatService:RegisterFilterMessageFunction(functionId, doFilter)
end
return runChatModule
‘speaker’ is not void due to when i do print(speaker) it prints my roblox username. And then theres no errors from the script due to it is roblox’s ChatService script that is giving the warning that i have posted but it is also below.
DoMessageFilter Function 'editText' failed for reason: Argument 1 missing or nil - Server - ChatService:396
Is there a way for it to only show the scrambled text to some users. (If your in a group it does not show scrambled text if your not in the group it shows scrambled text)