#13:39:17.657 Unable to cast double to token - Server - Script:223

5 messages · Page 1 of 1 (latest)

crystal meadow
#

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

#

the error is here

#

ChatService:RegisterChatCallback(player.UserId, onPlayerInput)

willow walrus
#

-- Sample ChatService module (ChatService.lua)
local ChatService = {}

function ChatService:RegisterChatCallback(userId, callback)
-- Your implementation to register a chat callback for the player with userId
-- This function should call the provided callback when a player with the given userId sends a chat message
-- You'll need to implement a way to handle player chat input and call the callback accordingly
end

return ChatService end

#

If doesnt work try this -- Main Script
local ChatService = require(game.ServerScriptService.ChatService) -- Replace the path with the actual path to your ChatService module

local function onPlayerInput(userId, message)
-- Handle the player's chat input here
print("Received chat input from player with UserId:", userId)
print("Message:", message)
end

-- Example usage for a specific player (replace with the actual player's UserId)
local player = game.Players:GetPlayerByUserId(123456789)
if player then
ChatService:RegisterChatCallback(player.UserId, onPlayerInput)
end