Server Message Help

Make sure it’s a local script and keep it somewhere that will be replicated under the player like starter player scripts.

Can’t you just use the PlayerAdded event?

PlayerAdded is for servers, game.Players.LocalPlayer is for local players.

how would you make the server message function? Do you see any errors?

I don’t know, do you know if in the Output you have any errors from the script? If you don’t have an Output, go to VIEW and open “Output”.

PlayerAdded fires on client, it just doesn’t fire for your own player. So it can be useful for detecting when players join after yours.

@Kamlkaze_Kid
Dude ur code looks fine, it runs in my studio. Where are u placing the code?

No errors in output or script analysis

In a serverscript in serverscriptservice because so I can do PlayerAdded

Alright, you’ll want that in a local script, StarterGui:SetCore() can’t be called on server.
If you want the server to delegate when a system message is made then you can use a remote event.

But since you’re not concatenating a player’s name with the system message, you probably don’t want the welcome to fire for every player added. So just try it as it is above in a local script.

@IAmPinleon Same conclusion

I don’t know if you can do game.StarterGui:SetCore(parameters) in a server script…

Just confirmed, @greatgavin posted before me :frowning:

1 Like

Which folder? (30 charsssssssss)

Go for a local script in StarterPlayerScripts, doesn’t matter to much tho as long as it runs on client.

1 Like

How about when a player joins? PlayerAdded?

You can do what @greatgavin said, but you can also do StarterGui.

So here is some sample code:

--server
local remote = path.to.remote

game.Players.PlayerAdded:Connect(function(plr)
    remote:FireClient(plr)
end)
--client
local remote = path.to.remote

remote.OnClientEvent:Connect(function()
    game.StarterGui:SetCore("ChatMakeSystemMessage", {
        Text = "{System} Welcome to Sprint Course!";
        Font = Enum.Font.Cartoon;
        Color = Color3.new(253, 251, 255);
        FontSize = Enum.FontSize.Size96
    })
end)
1 Like

local scripts in starter player scripts get cloned to each player when they join, so it’s like there’s a built in PlayerAdded function. Make it a local script and put it in starter player scripts, see if it works. You can’t use SetCore in a server script, which is why it wasn’t working. Your script looks good, don’t put it in a player added function or anything.

There’s no point in using a remote event for this. You can just put the local script in somewhere like starter player scripts and it will run right when the player joins anyway.

1 Like

Hey, I tried your code and it seemed to work perfectly fine for me.

Make sure that the code is as high as it can be in the script and not under any statements that may yield further instructions (example: if you have a while true do statement above this code then it wouldn’t work.

Also, make sure you’re using a localscript and not a serverscript. To read more about Server Scripts vs Local Scripts there is a thread here: LocalScript vs. Script help

Finally, make sure your code is in a locally replicated area. The most common being StarterGui and StarterPlayerScripts.

If you’re still having issues I’ve re-formatted the code along with sent a place file containing just the code.

Code
local StarterGui = game:GetService("StarterGui");

StarterGui:SetCore("ChatMakeSystemMessage", {
   Text = "{System} Welcome to Sprint Course!";
   Font = Enum.Font.Cartoon;
   Color = Color3.new(253, 251, 255);
   FontSize = Enum.FontSize.Size96
})

Place File: Chat-Notification.rbxl (18.1 KB)

1 Like

How would you randomize the text? (By using math.random?) Because through the game, I want text that is selected randomly to pop up? Also, how do you insert the players name into the text? ex “Hello! (PlayersName)!”

You can make a while loop that constantly sends that text.

local waitingtime = 100

while true do
local StarterGui = game:GetService("StarterGui");

StarterGui:SetCore("ChatMakeSystemMessage", {
   Text = "{System} Welcome to Sprint Course!";
   Font = Enum.Font.Cartoon;
   Color = Color3.new(253, 251, 255);
   FontSize = Enum.FontSize.Size96
})
wait(waitingtime)
end

(Sorry for the bad indenting, I’m on mobile)
If you want it to choose a random waiting time between messages, you can use math.random.

local waitingtime = math.random(LowestPossibleNumber, HighestPossibleNumber) 

You can insert the player’s name by getting the local player and checking it’s name property.

local player = game.Players.LocalPlayer

-- later on
local Text = "Hello "..player.Name.."!"

What I meant was like text that is chosen randomly throughout the game.