Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do I make a system message appear for everyone at the same time?

I have this script that runs system messages at different times. If I put it in a local script, each player gets it at a different time, but if I put it in a normal script, it doesn't work at all. Is there anyway to fix this? Here is the script: It gives this error when its in a normal script. https://gyazo.com/bad11f3082d741c6e5fe9290a7b9c740

game.Players.PlayerAdded:connect(function(player)
wait()
while true do
if game.Workspace.PlayerCount.Players.Value <= 5
    then
    game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "Waiting for at least FIVE players to join..",
    Color = Color3.new(100, 100, 0),
    Font = Enum.Font.SourceSansLight,
    FontSize = Enum.FontSize.Size18,
print("made it here lol")
    })
    wait(10)
end
  
wait()
if game.Workspace.PlayerCount.Players.Value >= 5
	and game.Workspace.game.CanCollide == true
	then
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "Welcome to the annual HUNGER GAMES",
    Color = Color3.new(100, 0, 0),
    Font = Enum.Font.SourceSansLight,
    FontSize = Enum.FontSize.Size18,
    })
player.TeamColor = BrickColor.new("Forest green")
	wait(10)
	game.Workspace.game.CanCollide = false
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "If you don't know how to play, read the description!",
    Color = Color3.new(0, 100, 0),
    Font = Enum.Font.SourceSansLight,
    FontSize = Enum.FontSize.Size18,
    	})
wait(10)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "Selecting random arena...",
    Color = Color3.new(100, 100, 530),
    Font = Enum.Font.SourceSansLight,
    FontSize = Enum.FontSize.Size18,
    	})
wait(5)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "Arena selected. Prepare to enter the game. May the odds be ever in your favor.",
    Color = Color3.new(322, 100, 0),
    Font = Enum.Font.SourceSansLight,
    FontSize = Enum.FontSize.Size18,
    	})
wait(20)
local Pos = player.Character:GetPrimaryPartCFrame()
					player:LoadCharacter()
					player.Character:SetPrimaryPartCFrame(Pos)
					if player.Character:FindFirstChild("ForceField") then
						player.Character["ForceField"]:Destroy()
						wait(1)
						game.ReplicatedStorage.Remotes.tp:FireServer()
						
	end					end
end
end)

3 comments

0

You shouldn’t be putting print statements inside a table. Line 11, put it under line 12 or line 13.

0

Also, connect is deprecated, switch to Connect.

0

1 answer

One way you could do this is to use RemoteEvents. Start by inserting a RemoteEvent into ReplicatedStrorage. Next create a script inside of Workspace or ServerScriptService and reference the RemoteEvent: Note All the code below is untested

local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent

You could then check if something has happened in the game. Note: It must be something to do with all players so that when this becomes true they will all see the message at the same time. After the condition is true you can fire it to the client

Here is an example:

local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent
local Toggle = false

while true do
	Toggle = true
	wait(120)
	Toggle = false
end

while wait(0.1) do
	if Toggle then
		RemoteEvent:FireClient()
	end
end

Now it's time to edit your LocalScript. You can use the RemoteEvent in the same way a normal event is used. Instead of PlayerAdded for instance you would type OnClientEvent (For the client):

local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent

RemoteEvent.OnClientEvent:Connect(function()
	--Message stuff
end)

One other problem is that when you connected your PlayerAdded event you used connect not Connect. Hopefully this help!

3 comments

0

can you be a little bit more in depth, I don't really understand what you mean

0

it'll be easier when you make your own code. experiment with remotes for now

0

Remote events allow you to communicate with the server and the client. FireClient will send the event to all clients. OnClientEvent is just like PlayerAdded but you choose when it gets fired.

This discussion is preserved as it was. New answers, comments, and votes are closed.