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?
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