【问题标题】:Message not showing after user joins sometimes有时用户加入后不显示消息
【发布时间】:2018-04-11 06:45:37
【问题描述】:

所以,我制作了这个聊天模块,当用户加入时,它会在聊天中显示本地消息,但有时当他们加入时消息不存在,但有时消息确实会出现。我认为这是因为播放器加载速度不够快?在运行消息代码之前是否可以等待播放器完全加载?我知道您可以在运行一些代码之前等待玩家加入,但我不知道如何在模块脚本中执行此操作(我已经尝试过)。这是我的脚本:

local function Run(ChatService)

local server = ChatService:AddSpeaker("Server")
server:JoinChannel("All")
local local_nick = nil

ChatService:GetChannel("All").SpeakerJoined:connect(function(speaker)
        spawn(function()        
            server:SayMessage(string.format("Hello %s, Welcome to Bailiann's F3X Building Place!",speaker),"All")
            server:SetExtraData("NameColor", Color3.new(
            150.0/255.0,
            167.0/255.0,
            255.0/255.0)
            )
            server:SetExtraData("ChatColor", Color3.new(
            249.0/255.0,
            207.0/255.0,
            249.0/255.0
            ))
        end)    
    end)
end
return Run

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    尝试使用新的 roblox setCore() 函数,但它仅适用于本地脚本。这是代码

    game.Players.PlayerAdded:connect(function(plr)
    wait() -- Sometimes this is required
    game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "Welcome to my game!"; -- Required. Has to be a string!
    Color = Color3.new(0, 1, 1); -- Cyan is (0, 255 / 255, 255 / 255). Optional, defaults to white: Color3.new(255 / 255, 255 / 255, 243 / 255)
    Font = Enum.Font.SourceSans; -- Optional, defaults to Enum.Font.SourceSansBold
    FontSize = Enum.FontSize.Size24; -- Optional, defaults to Enum.FontSize.Size18
    })
    
    end)
    

    希望这会有所帮助,如果不能确保将本地脚本放入 Starter Player -> StarterPlayerScripts

    【讨论】:

      猜你喜欢
      • 2021-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多