local playerPreferences = {} -- Initialize the playerPreferences table here
local function askPlayerPreferences(player)
local question = "Hey there! What are your interests? You can mention multiple topics, separated by commas."
createChat(question)
local function onPlayerInput(msg)
local selectedTopics = {}
local inputTopics = split(msg:lower(), ",")
for _, topic in ipairs(inputTopics) do
if table.find(topics, topic) then
table.insert(selectedTopics, topic)
end
end
if #selectedTopics > 0 then
playerPreferences[player.Name] = selectedTopics
createChat("Got it! I'll keep that in mind for our conversations.")
else
createChat("I'm sorry, I didn't catch that. Please tell me some of your interests.")
askPlayerPreferences(player)
end
end
ChatService:RegisterChatCallback(player.UserId, onPlayerInput)
end