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

Need Help With a Script That Opens a Gui When Countdown Finishes?

Asked by 7 years ago

OK So on line 69 I am having a problem with calling the Gui fro StarterGui. No matter what I do it will not make the Gui appear when the countdown is over.

Currently on line 69 I have game.StarterGui.Waves.Waves.Enabled = true I have also tried game.StarterGui.Waves.Waves.Frame.Visible = true amongst other calls to try to get it to show up.

I am thinking this is because it is not pointing toward the PlayerGui and instead is pointing to the Gui located in the StarterGui, However I have no idea how I to point it to a player without it being a local script. Can soeone help me revise this so it will show the Gui in this server script. Thanks in advance, any help is appreciated

game.ServerScriptService["Wave1 - PathFind"].ZombieScript.Disabled = false
game.ServerScriptService["Wave1 - PathFind"].ZombieScript1.Disabled = false
game.ServerScriptService["Wave1 - PathFind"].ZombieScript1d3.Disabled = false

disasters = {"Wave0"} -- This is where you list the names models that you want to use for disasters.
-- Disaster names are case-sensitive and all disaster models must be in the lighting

countdownTime = 5 -- The ammount of time to wait between each disaster.

countdownMessage = "You have %s to prepare." -- The message displayed between disasters. %s will be replaced with the number of seconds left.
disasterMessage = "Wave 1" -- The message displayed when a disaster occurs. %s will be replaced with the disaster name. Set to nil if you do not want a message

-- Unless you know what you are doing, please leave the below code alone.
items = {}
local w = game.Workspace:getChildren()



for i=1, #disasters do
    local item = game.ReplicatedStorage.Wave1:findFirstChild(disasters[i])
    if item ~= nil then
        item.Parent = nil
        table.insert(items, item)
    else
        print("Error! ", disasters[i], " was not found!")
    end
end

function chooseDisaster()
    return items[1]
end

function sethint(text)
    local hint = game.Workspace:findFirstChild("hint")
    if (hint ~= nil) then
        hint.Text = text
    else
        print("Hint does not exist, creating...")
        local h = Instance.new("Hint")
        h.Name = "hint"
        h.Text = text
        h.Parent = game.Workspace
    end
    --print("Hint set to: ", text)
end

function removeHint()
    local hint = game.Workspace:findFirstChild("hint")
    if (hint ~= nil) then hint:remove() end
end

function countdown(time)
    sethint(string.format(countdownMessage, tostring(time)))
    while (time > 0) do
        wait(1)
        time = time - 1
        sethint(string.format(countdownMessage, tostring(time)))
    end
    removeHint()
    return true
end

while true do
    countdown(countdownTime)

    local m = chooseDisaster():clone()
print("This is working")

 game.StarterGui.Waves.Waves.Enabled = true

print("This is working 2")

        wait(3)
        print("This is working 3")


    local m = chooseDisaster():clone()
    m.Parent = game.Workspace
    m:makeJoints()





break
end


3 answers

Log in to vote
0
Answered by 7 years ago

StarterGui is what goes into the PlayerGui when the player joins. So to enable the Gui you must access the PlayerGui. Like this:

Player.PlayerGui.Waves.Waves.Enabled = true
Ad
Log in to vote
0
Answered by
I_0KI 40
7 years ago

If you are trying to enable the gui for all players, this should work.

    for index, child in pairs(game.Players()) do
child.PlayerGui.Waves.Waves.Enabled = true
end
Log in to vote
0
Answered by
OfcPedroo 396 Moderation Voter
7 years ago

Hey CrazyRoblots, the guys there up already said the answer, but I just wanna tell you that's a bad practice. You shouldn't put the 'ScreenGui' class' 'Enabled' bool to 'true'. Inside that ScreenGui, there has to be childs, like Frames, TextLabels, or something like that. You should turn every ScreenGui childs 'Visible' bool (which is a property) to false, and then, in the script, change it to true.

For example, you have this

game > StarterGui > ExampleGui > ExampleFrame

you should start with ExampleFrame's 'Visible' bool on 'false' and then, in a local script,

game.Players.LocalPlayer.PlayerGui.ExampleGui.ExampleFrame.Visible = true

and not start ExampleGui's 'Enabled' bool on 'false' and then turn it on 'true', like

game.Players.LocalPlayer.PlayerGui.ExampleGui.Enabled = true

Hope I could, somehow, help.

0
Hey, Thanks for the advice. I am new to Game development and working in studio, only been around about 8 months now. I am learning something new everyday so thank you, I appreciate the help CrazyRoblots 13 — 7y
0
No worries, if you want more learning, add me on ROBLOX, and then ask me doubts. I'm into ROBLOX since quite a while, and know some more dev languages. OfcPedroo 396 — 7y

Answer this question