因此,我创建了这个聊天模块,当用户加入时,它会在聊天中显示本地消息,但有时当他们加入消息时,有时会显示消息。我认为这是因为玩家的加载速度不够快?是否可以在运行消息代码之前等待播放器完全加载?我知道你可以在运行一些代码之前等待玩家加入,但我不知道如何在模块脚本中这样做(我已经尝试过)。这是我的剧本:
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
答案 0 :(得分:0)
尝试并使用新的roblox setCore()函数,但它仅适用于localscripts。这是代码
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)
希望这有帮助,如果不确保将localscript放在Starter Player -> StarterPlayerScripts