Hello. I was going to switch a script to use TextChatCommand. The problem is that it doesn’t work.
Script:
local TextChatService = game:GetService("TextChatService")
local TTC = TextChatService.SpawnVehicle
local Main = {
["Whitelisted_UserId"] = {
205113231 -- grimmerschool2
}
}
local function GetCharacter(plr : Instance)
local character = plr.Character
if character then
return character
end
end
game.Players.PlayerAdded:Connect(function(plr)
for _, g in pairs(Main.Whitelisted_UserId) do
if plr.UserId == g then
TTC.Triggered:Connect(function(plr, msg)
local args = string.split(msg, " ")
for n, v in next, Main.cars do -- cars were in the main, i edited them out to not leak much
if string.lower(args[1]) == "/spawncar " .. n then
-- the stuff (im not leaking it)
print("skibidi")
end
end
end)
end
end
end)
Well you just made a memory leak by wrapping it in the PlayerAdded function. I believe it is meant to go inside of a local script which is placed in Starter player scripts or wherever else a local script runs. Then it communicates to the server when a command was said
I’m not at all familiar with Roblox’s new chat service, but looking at the documentation would suggest you should connect your car function to the chat commands Triggered event.
Also, you shouldn’t nest connections like that as it will take up memory fast
EDIT: The documentation says that the command needs to be parented to the service, which is not true. You have to add the command to the TextChatCommands folder after it is created for the command to be initialized.
Here’s a mockup of something that should work for you:
-- Running as server in ServerScriptService
local chat = game:GetService("TextChatService")
local whitelist = {3556485374} -- My id :)
local command = Instance.new("TextChatCommand")
command.Parent = chat:WaitForChild("TextChatCommands")
command.PrimaryAlias = "/skibidi"
command.SecondaryAlias = "/sk"
command.Triggered:Connect(function(originTextSource, unfilteredText)
if (table.find(whitelist, originTextSource.UserId)) then
doStuff()
print("skibidi")
end
end)