Well i was working on my game, I have seen server messages in a lot of games and i wanted to implement it to my game. As i was testing it I realized the code wasnt working and there was no server message. (server message was supposted to say Random dude joined the game [obviously with the name of the person that joined] and the same thing when someone leaft but with the player name has left the game). Didnt work so i came here to the forum hoping any of you developers could help me with it. Anyways here are the scripts I used.
local events = game.ReplicatedStorage.Events
game.Players.PlayerAdded:connect(function(plr) --when the player joins the game
events.Added:FireAllClients(plr)
end)
---
game.Players:PlayerRemoving:connect(function(plr) -- when the player leaves the game
events.Removing:FireAllClients(plr)
end)
that script is located in the workspace and its called Added/Removing
the other script is located in starter gui and its called Message and its a local script.
local events = game.ReplicatedStorage.Events
local starterGui = game.StarterGui
events.Added.OnClientEvent:connect(function(plr) --message when player joins the game
starterGui:SetCore("ChatMakeSystemMessage",{
Text = plr.Name.." has joined the game";
Color = Color3.fromRGB(0, 0, 255);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size32;
})
end)
---
events.Removing.OnClientEvent:connect(function(plr) --message when player leaves the game
starterGui:SetCore("ChatMakeSystemMessage",{
Text = plr.Name.." has left the game";
Color = Color3.fromRGB(0, 0, 255);
Font = Enum.Font.SourceSansBold;
FontSize = Enum.FontSize.Size32;
})
end)
I also have a folder called Events which is located in replicated storage and has two remote events in it one is called Added and the other one Removing. Thats about it hope anyone can help me and thanks for reading this post.