I have code that is making a chat message each time the player joins, but I am noticing that it only works for me and no one else. It is a local script found inside of starter player scripts. Does anyone know what may be causing this?
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[Server] " ..player.." joined the game!";
Color = Color3.new(0.333333, 1, 1);
Font = Enum.Font.FredokaOne;
FontSize = Enum.FontSize.Size24;
})
I only have this code for my join, do I need like a player joined event somewhere? I haven’t made a function yet, this seems to work but I can use a function if needed.
Correct me if I’m wrong, but since this is done in a local script the chat message will only come up for you, and you only.
I’m not pretty experienced with the chat module but as far as I know I think if you want this to be replicated to everyone, you do this from the server, and track player joins via PlayerAdded.
PlayerJoined event? I’ve never heard of this. This might be deprecated code, but as far as I know the only event that tracks player joins from the Players service is Players.PlayerAdded
I’m not sure quite what the problem is, the connection itself looks right though, so maybe I would use a Print(“Test”) to test if it is running the connection, if it is running the connection then the problem is to do something with the actual function itself and not the connection.
There’s really no error in this code, It’s about executing it.
You can simply put a localscript in StarterGui and write that same exact code and it’ll work for the local player, as a welcome message.
If you want whenever someone joins the game to also make a message then you’ll insert that script into a PlayerAdded connection.
Script:
local LocalPlayer = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
--This is the welcome message and will only appear to the local player.
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[Server] Hello! Welcome, "..LocalPlayer.Name.." to my game!";
Color = Color3.new(0.133333, 1, 0.568627);
Font = Enum.Font.FredokaOne;
FontSize = Enum.FontSize.Size24;
})
--This is for when someone joins, will appear for all players since they will have the same script in their PlayerGui.
game:GetService("Players").PlayerAdded:Connect(function(Player)
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[Server] " ..Player.Name.." joined the game!";
Color = Color3.new(0.333333, 1, 1);
Font = Enum.Font.FredokaOne;
FontSize = Enum.FontSize.Size24;
})
end)