Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
zValerian 108
6 years ago
Edited 6 years ago

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)
0
You shouldn’t be putting print statements inside a table. Line 11, put it under line 12 or line 13. User#19524 175 — 6y
0
Also, connect is deprecated, switch to Connect. User#19524 175 — 6y
0
this is the errr it gives: https://gyazo.com/bad11f3082d741c6e5fe9290a7b9c740 zValerian 108 — 6y

1 answer

Log in to vote
0
Answered by
zblox164 531 Moderation Voter
6 years ago

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!

0
can you be a little bit more in depth, I don't really understand what you mean zValerian 108 — 6y
0
it'll be easier when you make your own code. experiment with remotes for now masterblokz 58 — 6y
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. zblox164 531 — 6y
Ad

Answer this question