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

[SOLVED] How to show a GUI to all players at once?

Asked by 6 years ago
Edited 6 years ago

Hello, I would like some help on how to show a GUI to all players at once. This script is placed in ServerScriptService

Here is my script:

local startGui = game.ServerStorage.StartingGui
local doomGui = game.ServerStorage.DoomMessageGui

while true do
    wait(60)
    for i, v in pairs(game.Players:GetPlayers()) do
        if v:FindFirstChild("PlayerGui") then -- Check for PlayerGui
            local startGuiClone = startGui:Clone()
            startGuiClone.Parent = v.PlayerGui
            wait(1)
            startGuiClone.Frame.Timer.Text = "[9]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[8]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[7]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[6]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[5]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[4]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[3]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[2]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[1]"
            wait(1)
            startGuiClone.Frame.Timer.Text = "[0]"
            wait(1)
            startGuiClone:Destroy()
            game.Workspace[v.Name].HumanoidRootPart.CFrame = CFrame.new(game.Workspace.DoomBuilding.TeleportPosition.Position)
            wait(5)
            local doomGuiClone = doomGui:Clone()
            doomGuiClone.Parent = v.PlayerGui
            wait(1)
            doomGuiClone.Text.Text = "Ready"
            wait(1)
            doomGuiClone.Text.Text = "Avoid your Doom!"
            wait(1)
            doomGuiClone:Destroy()
            game.Workspace.DoomBuilding.DoomFloor.CanCollide = false
            game.Workspace.DoomBuilding.DoomFloor.Transparency = 1
            wait(10)
            game.Workspace[v.Name].HumanoidRootPart.CFrame = CFrame.new(game.Workspace.DoomBuilding.SpectatorArea.EndTeleportArea.Position)
            game.Workspace.DoomBuilding.DoomFloor.CanCollide = true
            game.Workspace.DoomBuilding.DoomFloor.Transparency = 0
        end
    end
end

There was no output. Any help would be appreciated

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You should use a RemoteEvent. Create a RemoteEvent in ReplicatedStorage and rename it to "Sync" or something, then you will need to place this in your script:

 Sync = game.ReplicatedStorage.Sync --Define the Variable
Sync:FireAllClients("Any Text You Want") --This Sends "Any Text You Want to all Clients"

Also, you will need in your GUI to create a local script

It should look something like this

game.ReplicatedStorage:WaitForChild("Sync").OnClientEvent:connect(function(msg)
    script.Parent.Text = msg
end)
--This function gets the Sync Data and changes the Text

Now that you know that, your script should look like this:

local startGui = game.ServerStorage.StartingGui
local doomGui = game.ServerStorage.DoomMessageGui
Sync = game.ReplicatedStorage.Sync --Define the Variable

while true do
    wait(60)
    for i, v in pairs(game.Players:GetPlayers()) do
        if v:FindFirstChild("PlayerGui") then -- Check for PlayerGui
            local startGuiClone = startGui:Clone()
            startGuiClone.Parent = v.PlayerGui --You don't need to create the PlayerGui now that you are using this method
            wait(1)
            Sync:FireAllClients("[9]") --Also you should use For, instead of waiting 1 seconds and pasting the countdown one by one
            wait(1)
            Sync:FireAllClients("[8]")
            wait(1)
            Sync:FireAllClients("[7]")
            wait(1)
            Sync:FireAllClients("[6]")
            wait(1)
            Sync:FireAllClients("[5]")
            wait(1)
            Sync:FireAllClients("[4]")
            wait(1)
            Sync:FireAllClients("[3]")
            wait(1)
            Sync:FireAllClients("[2]")
            wait(1)
            Sync:FireAllClients("[1]")
            wait(1)
            Sync:FireAllClients("[0]")
            wait(1)
            startGuiClone:Destroy()
            game.Workspace[v.Name].HumanoidRootPart.CFrame = CFrame.new(game.Workspace.DoomBuilding.TeleportPosition.Position)
            wait(5)
            local doomGuiClone = doomGui:Clone()
            doomGuiClone.Parent = v.PlayerGui
            wait(1)
            doomGuiClone.Text.Text = "Ready"
            wait(1)
            doomGuiClone.Text.Text = "Avoid your Doom!"
            wait(1)
            doomGuiClone:Destroy()
            game.Workspace.DoomBuilding.DoomFloor.CanCollide = false
            game.Workspace.DoomBuilding.DoomFloor.Transparency = 1
            wait(10)
            game.Workspace[v.Name].HumanoidRootPart.CFrame = CFrame.new(game.Workspace.DoomBuilding.SpectatorArea.EndTeleportArea.Position)
            game.Workspace.DoomBuilding.DoomFloor.CanCollide = true
            game.Workspace.DoomBuilding.DoomFloor.Transparency = 0
        end
    end
end

And don't forget to create the local script in your GUI Text

0
Thank you! ProvingTrottle 27 — 6y
Ad

Answer this question