Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

2 comments

0

If the button is a GUI you should use MouseButton1Click. If that was intended, I probably misinterpreted what the script is doing.

0

its a union

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.