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

Why won't this disaster script change the hintgui test?

Asked by
yoshi8080 445 Moderation Voter
8 years ago

I didn't make this whole script, But I'm making edits where the hints are replaced with guis... The text does show, but it doesn't change?

disasters = {"Noob","Zombie"}

countdownTime = 15
disasterTime = 45

countdownMessage = "The next disaster will occur in %s seconds."
disasterMessage = "Disaster: %s"

items = {}
leaderboard = game.Workspace:findFirstChild("BTS Leaderboard")
local w = game.Workspace:getChildren()
for i=1,#w do
    if w[i].Name == "leaderboard" and w[i]:findFirstChild("running") ~= nil and w[i]:findFirstChild("points") ~= ni then
        leaderboard = w[i]
    end
end
for i=1,#disasters do
    local item = game.Lighting: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[math.random(#items)]
end

function sethint(text)
    local hint = game.StarterGui:findFirstChild("HintGui")
    if (hint ~= nil) then
        hint.Frame.HintText.Text = text
    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
    return true
end

while true do
    countdown(countdownTime)
    if leaderboard ~= nil and leaderboard:findFirstChild("running") and leaderboard:findFirstChild("points") then
        leaderboard.points.Value = 30
        leaderboard.running.Value = true
    end

    local m = chooseDisaster():clone()

    if disasterMessage ~= nil then
        local msg = Instance.new("Message")
        msg.Name = "DisasterMsg"
        msg.Text = string.format(disasterMessage, m.Name)
        msg.Parent = game.Workspace
        wait(3)
        msg.Parent = nil
    end

    m.Parent = game.Workspace
    m:makeJoints()
    wait(disasterTime)
    m:remove()

    if leaderboard ~= nil then
        leaderboard.running.Value = false
    end
end

Pls find out why the text doesn't change when it counts down?

Answer this question