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

Why did my gui script stop working when it was working fine yesterday?

this is the script:

wait(3)
local PlayerGui = game.Players.LocalPlayer.PlayerGui
PlayerGui.Events.BlackScreen.Visible = true
PlayerGui.Nights.Night1.Visible = true
PlayerGui.Nights.Night2.Visible = true
PlayerGui.Nights.Night3.Visible = true
PlayerGui.Nights.Night4.Visible = true
PlayerGui.Nights.Night5.Visible = true


PlayerGui.Nights.Night1.MouseButton1Down:Connect(Night1())


function Night1()
	PlayerGui.Nights.Night1.Visible = false
	PlayerGui.Nights.Night2.Visible = false
	PlayerGui.Nights.Night3.Visible = false
	PlayerGui.Nights.Night4.Visible = false
	PlayerGui.Nights.Night5.Visible = false
end

it worked before but its broke now, help

5 comments

0

I spent 10 minutes trying to come up with a title that worked. The system is stupid just gonna say that.

0

I believe you have to define the function before calling it, so you would move the Night1 function to line 10

0

ok did that but my main concern now is that the "Nights" arent turning visible

0

did you try what b_mni posted as an answer? it should look exactly like that

0

yes

2 answers

fix:

wait(3)
local PlayerGui = script.Parent.PlayerGui
PlayerGui.Events.BlackScreen.Visible = true
PlayerGui.Nights.Night1.Visible = true
PlayerGui.Nights.Night2.Visible = true
PlayerGui.Nights.Night3.Visible = true
PlayerGui.Nights.Night4.Visible = true
PlayerGui.Nights.Night5.Visible = true

local IsVisible = true

function Night1()
    if IsVisible = true then
    PlayerGui.Nights.Night1.Visible = false
    PlayerGui.Nights.Night2.Visible = false
    PlayerGui.Nights.Night3.Visible = false
    PlayerGui.Nights.Night4.Visible = false
    PlayerGui.Nights.Night5.Visible = false
    IsVisible = false
    else
    PlayerGui.Nights.Night1.Visible = true
    PlayerGui.Nights.Night2.Visible = true
    PlayerGui.Nights.Night3.Visible = true
    PlayerGui.Nights.Night4.Visible = true
    PlayerGui.Nights.Night5.Visible = true
    IsVisible = true
    end
end

PlayerGui.Nights.Night1.MouseButton1Down:Connect(Night1)

7 comments

0

i think

0

ok did that but my main concern now is that the "Nights" arent turning visible

0

do you mean that when you turn them off, they aren't turning visible again?

0

Are you doing this in normal script?

0

no local in starter player scripts

0

im making an edit

0

done

What you need to do is check if they are set to visible, and if they are make them invisible, and the other way around:

wait(3)
local PlayerGui = game.Players.LocalPlayer.PlayerGui
PlayerGui.Events.BlackScreen.Visible = true
PlayerGui.Nights.Night1.Visible = true
PlayerGui.Nights.Night2.Visible = true
PlayerGui.Nights.Night3.Visible = true
PlayerGui.Nights.Night4.Visible = true
PlayerGui.Nights.Night5.Visible = true

local visible = true

function Night1()
	if visible then
		PlayerGui.Nights.Night1.Visible = false
	    PlayerGui.Nights.Night2.Visible = false
	    PlayerGui.Nights.Night3.Visible = false
	    PlayerGui.Nights.Night4.Visible = false
	    PlayerGui.Nights.Night5.Visible = false
		visible = false
	elseif not visible then
		PlayerGui.Nights.Night1.Visible = true
	    PlayerGui.Nights.Night2.Visible = true
	    PlayerGui.Nights.Night3.Visible = true
	    PlayerGui.Nights.Night4.Visible = true
	    PlayerGui.Nights.Night5.Visible = true
		visible = true
	end
end

PlayerGui.Nights.Night1.MouseButton1Down:Connect(Night1())

5 comments

0

still doesnt work :/

0

try the edited script

0

i di

0

i did but it still doesnt work

0

are you sure the other parts of your script works? because we are just formatting it correctly for you

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