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

Script in module not doing anything? No errors, no output?

Asked by 6 years ago

I have the following module:

local module = {}

function module.Startup(Screen, On)

    if On == false then 
    On = true
    Screen.Enabled = true
    Screen.Loading.Visible = true
    wait(1)
    Screen.Loading.Logo.Visible = true
    wait(2)
    Screen.Loading.ProgressBar.Visible = true
    Screen.Loading.ProgressBox = true
    local y = 0
        while y < 1 do
            y = y + 0.01
            Screen.Loading.ProgressBar.Size = UDim2.new(y ,0 ,0, 10)
            if On == false then
                break
            end
            wait()
        end 
    else
    On = false
    Screen.Enabled = false
    Screen.Loading.Visible = false
    Screen.Loading.Logo.Visible = false
    Screen.Loading.ProgressBar.Visible = false
    Screen.Loading.ProgressBox.Visible = false
    Screen.Loading.ProgressBar.Size = UDim2.new(0, 0, 0, 10)
    end
end


return module

And the script that requires it, inside a button:

local Screen = script.Parent.Parent.Screen.Screen
local Functions = require(script.Parent.Parent.Functions)
local On = script.Parent.Parent.On

script.Parent.ClickDetector.MouseClick:Connect(function() Functions.Startup(Screen, On) end)

When the button is pressed nothing happens, On's value doesn't even change. No errors, nothing in output. What's wrong?

0
If the button is a GUI you should use MouseButton1Click. If that was intended, I probably misinterpreted what the script is doing. ThatPreston 354 — 6y
0
its a union radusavin366 617 — 6y

1 answer

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

I assume the script.Parent.Parent.On is a Boolean Value? If so, then you should use its Value property.

By calling the Startup function with (Screen, On) you pass the BoolValue instance and not it's value. And an instance will never equal false. So what you should do is call it with (Screen, On.Value) OR make the first script operate on its value instead of a boolean, like so:

local module = {}

function module.Startup(Screen, On)

    if On.Value == false then 
    On.Value = true
    Screen.Enabled = true
    Screen.Loading.Visible = true
    wait(1)
    Screen.Loading.Logo.Visible = true
    wait(2)
    Screen.Loading.ProgressBar.Visible = true
    Screen.Loading.ProgressBox = true
    local y = 0
        while y < 1 do
            y = y + 0.01
            Screen.Loading.ProgressBar.Size = UDim2.new(y ,0 ,0, 10)
            if On == false then
                break
            end
            wait()
        end 
    else
    On.Value = false
    Screen.Enabled = false
    Screen.Loading.Visible = false
    Screen.Loading.Logo.Visible = false
    Screen.Loading.ProgressBar.Visible = false
    Screen.Loading.ProgressBox.Visible = false
    Screen.Loading.ProgressBar.Size = UDim2.new(0, 0, 0, 10)
    end
end


return module
Ad

Answer this question