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

Script stops working and prints nothing to the output?

Asked by
traigla 75
9 years ago

It was working fine before, but all of a sudden it stopped, any help is greatly appreciated. I know the DataStore is not efficient, but I wanted to do it this way and it worked before. From what I could tell, the script stops at 'gui.CanProceed.Value = false' and does run that line, but does not run the final line. I'm pretty sure that it's also not saving.

local Sec1 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec1")
local Sec2 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec2")
local Sec3 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec3")
local Sec4 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec4")
local key = "user_" .. script.Parent.Parent.Parent.userId
local gui = script.Parent
local mainpanel = gui.MainPanel
local course_sections = gui.Course_Sections
local page_home = mainpanel.Page_Home
local page_section = mainpanel.Page_Section
local custom_sections = gui.Custom_Sections
local open = true

page_section.Body.Proceed_Button.MouseButton1Down:connect(function()
    if gui.CurrentSectionOpen.Value == 1 then
        course_sections.Section_1.Completed.Value = true
        Sec1:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    elseif gui.CurrentSectionOpen.Value == 2 then
        course_sections.Section_2.Completed.Value = true
        Sec2:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    elseif gui.CurrentSectionOpen.Value == 3 then
        course_sections.Section_3.Completed.Value = true
        Sec3:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    elseif gui.CurrentSectionOpen.Value == 4 then
        course_sections.Section_4.Completed.Value = true
        Sec4:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    end
    if page_section.Body:FindFirstChild("Section_1") then
        local toRemove = page_section.Body:FindFirstChild("Section_1")
        toRemove:remove()
    end
    if page_section.Body:FindFirstChild("Section_2") then
        local toRemove = page_section.Body:FindFirstChild("Section_2")
        toRemove:remove()
    end
    if page_section.Body:FindFirstChild("Section_3") then
        local toRemove = page_section.Body:FindFirstChild("Section_3")
        toRemove:remove()
    end
    if page_section.Body:FindFirstChild("Section_4") then
        local toRemove = page_section.Body:FindFirstChild("Section_4")
        toRemove:remove()
    end
    gui.CurrentSectionOpen.Value = 0
    page_section.Visible = false
    page_home.Visible = true
    gui.CanProceed.Value = false
    mainpanel.MainHeader.PageTitle.Text = "You are at: Home"
end)

1 answer

Log in to vote
0
Answered by
KenzaXI 166
9 years ago

Try this :

while true do
local Sec1 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec1")
local Sec2 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec2")
local Sec3 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec3")
local Sec4 = game:GetService("DataStoreService"):GetDataStore(script.Parent.RankName.Value.."sec4")
local key = "user_" .. script.Parent.Parent.Parent.userId
local gui = script.Parent
local mainpanel = gui.MainPanel
local course_sections = gui.Course_Sections
local page_home = mainpanel.Page_Home
local page_section = mainpanel.Page_Section
local custom_sections = gui.Custom_Sections
local open = true

page_section.Body.Proceed_Button.MouseButton1Down:connect(function()
    if gui.CurrentSectionOpen.Value == 1 then
        course_sections.Section_1.Completed.Value = true
        Sec1:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    elseif gui.CurrentSectionOpen.Value == 2 then
        course_sections.Section_2.Completed.Value = true
        Sec2:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    elseif gui.CurrentSectionOpen.Value == 3 then
        course_sections.Section_3.Completed.Value = true
        Sec3:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    elseif gui.CurrentSectionOpen.Value == 4 then
        course_sections.Section_4.Completed.Value = true
        Sec4:UpdateAsync(key, function()
            local newValue = true
            return newValue
        end)
    end
    if page_section.Body:FindFirstChild("Section_1") then
        local toRemove = page_section.Body:FindFirstChild("Section_1")
        toRemove:remove()
    end
    if page_section.Body:FindFirstChild("Section_2") then
        local toRemove = page_section.Body:FindFirstChild("Section_2")
        toRemove:remove()
    end
    if page_section.Body:FindFirstChild("Section_3") then
        local toRemove = page_section.Body:FindFirstChild("Section_3")
        toRemove:remove()
    end
    if page_section.Body:FindFirstChild("Section_4") then
        local toRemove = page_section.Body:FindFirstChild("Section_4")
        toRemove:remove()
    end
    gui.CurrentSectionOpen.Value = 0
    page_section.Visible = false
    page_home.Visible = true
    gui.CanProceed.Value = false
    mainpanel.MainHeader.PageTitle.Text = "You are at: Home"
end)

end
Ad

Answer this question