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

Can anyone tell me what i have to add in the line of the localscript where it says gui object?

So, I found this script and i want to use it to make it so that when you click a part, your screen fades to black and then fades out:

local debounce = false
local faded = false

game.ReplicatedStorage.FadeGui.OnClientEvent:Connect(function()
    if debounce == false then
        debounce = true
        if faded == false then
            faded = true
            for i = 0, 1, 0.05 do
                script.Parent:WaitForChild(THE GUI OBJECT YOU WANNA FADE).BackgroundTransparency = i
                wait(.05)
            end
            return -- returning to the beginning of the function to not run the following lines, after setting "faded" to true
          else
            faded = false
            for i = 1, 0, -0.05 do
                script.Parent:WaitForChild(THE GUI OBJECT YOU WANNA FADE).BackgroundTransparency = i
            wait(.05)
        end
        debounce = false
    end
end)

the thing is that i don't know what a Gui Object is, could anyone tell me?

1 answer

✓ Accepted answer

Hi,

it really seems that you need to familiarise yourself with the explorer tab. If you dont have it open, go to the top, select **view ** and select explorer.

Now to find out what a GUI object is.

  • In the explorer, you will find a lot of (lets call it folders) and one of them is called Starter GUI

  • hover over to Starter GUI and click on the + (plus) button next to it.

  • Now you will see a drop - down menu.

  • From the dropdown menu, select Screen GUI - this is what allows GUIs to be displayed

  • Next, hover over to Screen GUI and select the + icon

  • from the dropdown menu, select a frame - you will see a white square somewhere on your screen now -> the frame is the GUI object

  • now, its pretty simple, rescale your frame to cover up the screen

  • Now if you want to customise your frame go to view -> properties and you can change colour etc.

  • now on the script write the name of your GUI object - the frame (it should be called "Frame")

REMEMBER THE SCRIPT IS CASE-SENSITIVE SO WRITE - Frame

Ask me if you have any questions

Heres the script after youve made the gui

local debounce = false
local faded = false

game.ReplicatedStorage.FadeGui.OnClientEvent:Connect(function()
    if debounce == false then
        debounce = true
        if faded == false then
            faded = true
            for i = 0, 1, 0.05 do
                script.Parent:WaitForChild("Frame").BackgroundTransparency = i
                wait(.05)
            end
            return -- returning to the beginning of the function to not run the following lines, after setting "faded" to true
          else
            faded = false
            for i = 1, 0, -0.05 do
                script.Parent:WaitForChild("Frame").BackgroundTransparency = i
            wait(.05)
        end
        debounce = false
    end
end)

also put this script inside screen gui

1 comment

0

Oh god, I'm so dumb, i actually forgot about the "" in that line, i thought that it could've been the frame, and i wrote the name of the Frame without the "" thinking that i was wrong. That's embarassing lol. Thank you.

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