Hello all! I have an error in my code, the join only works for me.
I would like it to show something in the chat every time another player joins the game. Here is the code:
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[Server] "..player.." joined the game!";
Color = Color3.new(1, 1, 1);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size24;
})
function onPlayerAdded(plr)
RemoteEvent:FireAllClient(plr)
end
LOCAL SCRIPT
function onRemoteEvent(plr)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "[Server] "..plr.." joined the game!";
Color = Color3.new(1, 1, 1);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size24;
})
As that script you made will only show up for the player that joined.
CreateMessage = function(text, color, font, size)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = text;
Color = color;
Font = font;
FontSize = size;
})
end
if game:GetService("Workspace"):WaitForChild("Values"):WaitForChild("JoinsInitialized").Value == false then
game:GetService("Workspace"):WaitForChild("Values"):WaitForChild("JoinsInitialized").Value = true
CreateMessage(game:GetService("Players").LocalPlayer.Name.." has joined the game!", Color3.new(255/255, 230/255, 34/255), Enum.Font.SourceSans, Enum.FontSize.Size24)
end
game.Players.PlayerAdded:Connect(function(plr)
CreateMessage(plr.Name.." has joined the game!", Color3.new(255/255, 230/255, 34/255), Enum.Font.SourceSans, Enum.FontSize.Size24)
end)
game.Players.PlayerRemoving:Connect(function(plr)
CreateMessage(plr.Name.." has left the game!", Color3.new(255/255, 88/255, 88/255), Enum.Font.SourceSans, Enum.FontSize.Size24)
end)