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

How do I make a GUI run server-sided? [ANSWERED]

Asked by 10 years ago

****Hello, everyone, I just joined around 3 minutes ago. Anyways, I'm gonna ask a question, I need to create a GUI that runs server-sided. The reason why is because there is a sound that plays every time it loops until it reaches zero. [BASICALLY A COUNTDOWN] I don't know if I need to put the sound in Workspace, or somewhere else, but I noticed that when my friend joined, the server began playing that sound.

So how do I make the GUI equal to everyone seeing it? Do I have to use some sort of external script? Or is it an error of some sort?

If you wanna see the code, well then here it is. -

p = script.Parent

while true do
    for crazy1 = 20, 1, -1 do
        p.Text = "Intermission ends in " ..crazy1.. " seconds."
        game.Workspace.Clock:Play()
        wait(1)
    end
    if p.Text == "Intermission ends in 1 seconds." then
        wait(1)
        p.Text = "Are you ready?"
        wait(2)
        p.Text = "Are you set?"
        wait(2)
        p.Text = "BUILD!"
        wait(2)
        for crazy2 = 300, 1, -1 do
            p.Text = "Building session ends in " ..crazy2.. " seconds."
            wait(1)
        end
        if p.Text == "Building session ends in 1 seconds." then
            wait(1)
            p.Text = "Building session over!"
            wait(2)
            p.Text = "Now it is time to open the garage doors!"
            wait(5)
            p.Text = "Sleddin' time!"
            wait(2)
            for crazy3 = 100, 1, -1 do
                p.Text = "Sledding session ends in " ..crazy3.. " seconds."
                if p.Text == "Sledding session ends in 1 seconds." then
                    wait(1)
                    p.Text = "Closing garage doors..."
                    wait(1)
                end
            end
        end
    end
end

By the way, this isn't a request, only a question I need answered, I tried using the scripting forum, but they're extremely inactive?

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

You can't directly.

You have a few options, some which may be better than others. Here's a few ways you could do it, and none of them are complicated


Client Copying) Keep the values that need to be replicated either in _G or String/NumberValue s. The server changes these values, and all guis constantly watch them, updating them to their respective slots (either using the Changed event or just a constantly loop).

This works best if the GUI objects that you have simple and fairly static (like just one main message).


Server Updating) Sort of the opposite of the previous method. Instead of the client grabbing the values from the server, whenever the Server changes a value, it writes it to each player's PlayerGui. This may be more complicated because of dealing with new players and more complicated context-aware changes like knowing to hide something if a message is empty, or the like.


Easy) Most likely the simplest solution would be to keep a copy of the GUI objects in ReplicatedStorage, and have a server script constantly modifying them. A script in each player would constantly copy this GUI into the player's and delete the old one (or just update the values).

This way, you don't have to think about making something which keeps track of changes to the GUI. It will react well to any change you make, however complicated.

Note that whatever script on the server is managing the ScreenGui should probably be not in the ScreenGui, or otherwise devise a way to not copy it to the clients.

This will probably have some performance problems in some cases.

0
Thanks bro, +1. spacegang 16 — 10y
0
Remember to actually press the checkmark so other people notice this answer too BlueTaslem 18071 — 10y
Ad

Answer this question