Gui script not working

Hello, my name is Dani and I’m a very basic scripter. I’m struggling on trying to find out why my script isn’t working. If someone could try to fix it for me and explain what I was doing wrong, I’d appreciate it.

--LOCALS

local SP = script.Parent --MOST IMPORTANT
--Frames
local coinFrame = SP.CoinsDisplayMain
local settingFrame = SP.SettingsMain
local mainFrame = SP
--Buttons
local upButton = SP.Up
local downButton = SP.Down
local slideButton = SP.Slide
--Sounds
local soundService = game.SoundService
local settingsSound = soundService.MainGUISounds["O/PSound"]
local Coinsound = soundService.MainGUISounds["O/PSound"]
local pageSound = game.SoundService.MainGUISounds.PageSound
local slideSound = soundService.MainGUISounds.SlideSound
--True/False
local settingOn = false
local coinOn = false
local slideOn = false

-------------------------------------------------------------------------------------------------

--Settings Button Function
local function settingfunc()

		settingsSound:Play()

		if settingOn then 
			settingFrame.Visible = false
			settingOn = false
			SP.SettingsOC.text = "Open Settings"
			SP.CoinOC.Visible = true
			SP.Items.Visible = true
		else
			settingFrame.Visible = true
			settingOn = true
			SP.SettingsOC.text = "Close Settings"
			SP.CoinOC.Visible = false
			SP.Items.Visible = false
		end

-------------------------------------------------------------------------------------------------

--Coin Shop Function
local function coinfunc()

		Coinsound:Play()


		if coinOn then 
			coinFrame.Visible = false
			coinOn = false
			SP.CoinOC.text = "Open Coin Shop"
			SP.SettingsOC.Visible = true
			SP.Items.Visible = true
		else
			coinFrame.Visible = true
			coinOn = true
			SP.CoinOC.text = "Close Coin Shop"
			SP.SettingsOC.Visible = false
			SP.Items.Visible = false
		end

-------------------------------------------------------------------------------------------------

--Slide In/Out Function
local function slidefunc()

		slideSound:Play()


		if slideOn then 
			mainFrame:TweenPosition(UDim2.new(-0.19,0,0.015,0),"In","Sine",.5,true)
			slideOn=false
			mainFrame.Text = ">"
		else
			mainFrame:TweenPosition(UDim2.new(0.011,0,0.015,0),"Out","Back",1,true)
			slideOn=true
			mainFrame.Text = "<"
		end
	
-------------------------------------------------------------------------------------------------
	
	--Functions
	SP.SettingsOC.MouseButton1Click:Connect(settingfunc())
	slideButton.MouseButton1Click:Connect(settingfunc())
	SP.CoinOC.MouseButton1Click:Connect(coinfunc())

What I’m trying to do is combine 3 scripts I have, a script that opens a frame when button is clicked, another script that opens a frame when button is clicked (Both with closing feature by clicking the same button again, both buttons control different frames) and the last, Is a script that opens and closes the main frame of my GUI with a animated opening and closing.

2 Likes

What is not working, is there a error, or is it not doing what you want?

1 Like

When I click the buttons nothing happens.

1 Like

Try this:

--LOCALS

local SP = script.Parent --MOST IMPORTANT
--Frames
local coinFrame = SP.CoinsDisplayMain
local settingFrame = SP.SettingsMain
local mainFrame = SP
--Buttons
local upButton = SP.Up
local downButton = SP.Down
local slideButton = SP.Slide
--Sounds
local soundService = game.SoundService
local settingsSound = soundService.MainGUISounds["O/PSound"]
local Coinsound = soundService.MainGUISounds["O/PSound"]
local pageSound = game.SoundService.MainGUISounds.PageSound
local slideSound = soundService.MainGUISounds.SlideSound
--True/False
local settingOn = false
local coinOn = false
local slideOn = false

-------------------------------------------------------------------------------------------------

--Settings Button Function
local function settingfunc()

		settingsSound:Play()

		if settingOn then 
			settingFrame.Visible = false
			settingOn = false
			SP.SettingsOC.text = "Open Settings"
			SP.CoinOC.Visible = true
			SP.Items.Visible = true
		else
			settingFrame.Visible = true
			settingOn = true
			SP.SettingsOC.text = "Close Settings"
			SP.CoinOC.Visible = false
			SP.Items.Visible = false
		end

-------------------------------------------------------------------------------------------------

--Coin Shop Function
local function coinfunc()

		Coinsound:Play()


		if coinOn then 
			coinFrame.Visible = false
			coinOn = false
			SP.CoinOC.text = "Open Coin Shop"
			SP.SettingsOC.Visible = true
			SP.Items.Visible = true
		else
			coinFrame.Visible = true
			coinOn = true
			SP.CoinOC.text = "Close Coin Shop"
			SP.SettingsOC.Visible = false
			SP.Items.Visible = false
		end

-------------------------------------------------------------------------------------------------

--Slide In/Out Function
local function slidefunc()

		slideSound:Play()


		if slideOn then 
			mainFrame:TweenPosition(UDim2.new(-0.19,0,0.015,0),"In","Sine",.5,true)
			slideOn=false
			mainFrame.Text = ">"
		else
			mainFrame:TweenPosition(UDim2.new(0.011,0,0.015,0),"Out","Back",1,true)
			slideOn=true
			mainFrame.Text = "<"
		end
	
-------------------------------------------------------------------------------------------------
	
	--Functions
	SP.SettingsOC.MouseButton1Click:Connect(settingfunc)
	slideButton.MouseButton1Click:Connect(settingfunc)
	SP.CoinOC.MouseButton1Click:Connect(coinfunc)
1 Like

Unfortunately, That did not work.

1 Like

Try this:

--LOCALS

local SP = script.Parent --MOST IMPORTANT
--Frames
local coinFrame = SP.CoinsDisplayMain
local settingFrame = SP.SettingsMain
local mainFrame = SP
--Buttons
local upButton = SP.Up
local downButton = SP.Down
local slideButton = SP.Slide
--Sounds
local soundService = game.SoundService
local settingsSound = soundService.MainGUISounds["O/PSound"]
local Coinsound = soundService.MainGUISounds["O/PSound"]
local pageSound = game.SoundService.MainGUISounds.PageSound
local slideSound = soundService.MainGUISounds.SlideSound
--True/False
local settingOn = false
local coinOn = false
local slideOn = false

-------------------------------------------------------------------------------------------------

--Settings Button Function
local function settingfunc()

		settingsSound:Play()

		if settingOn then 
			settingFrame.Visible = false
			settingOn = false
			SP.SettingsOC.text = "Open Settings"
			SP.CoinOC.Visible = true
			SP.Items.Visible = true
		else
			settingFrame.Visible = true
			settingOn = true
			SP.SettingsOC.text = "Close Settings"
			SP.CoinOC.Visible = false
			SP.Items.Visible = false
		end
end

-------------------------------------------------------------------------------------------------

--Coin Shop Function
local function coinfunc()

		Coinsound:Play()


		if coinOn then 
			coinFrame.Visible = false
			coinOn = false
			SP.CoinOC.text = "Open Coin Shop"
			SP.SettingsOC.Visible = true
			SP.Items.Visible = true
		else
			coinFrame.Visible = true
			coinOn = true
			SP.CoinOC.text = "Close Coin Shop"
			SP.SettingsOC.Visible = false
			SP.Items.Visible = false
		end
end

-------------------------------------------------------------------------------------------------

--Slide In/Out Function
local function slidefunc()

		slideSound:Play()


		if slideOn then 
			mainFrame:TweenPosition(UDim2.new(-0.19,0,0.015,0),"In","Sine",.5,true)
			slideOn=false
			mainFrame.Text = ">"
		else
			mainFrame:TweenPosition(UDim2.new(0.011,0,0.015,0),"Out","Back",1,true)
			slideOn=true
			mainFrame.Text = "<"
		end
end
	
-------------------------------------------------------------------------------------------------
	
	--Functions
	SP.SettingsOC.MouseButton1Click:Connect(settingfunc)
	slideButton.MouseButton1Click:Connect(settingfunc)
	SP.CoinOC.MouseButton1Click:Connect(coinfunc)

(You where missing ends on your functions)

1 Like

Still did not work, I also made a mistake on the second to last line slidebutton.mousebutton1click:Connect(settingfunc) is supposed to be slidebutton.mousebutton1click:Connect(slidefunc)

1 Like

I think this will work:

--LOCALS

local SP = script.Parent --MOST IMPORTANT
--Frames
local coinFrame = SP.CoinsDisplayMain
local settingFrame = SP.SettingsMain
local mainFrame = SP
--Buttons
local upButton = SP.Up
local downButton = SP.Down
local slideButton = SP.Slide
--Sounds
local soundService = game.SoundService
local settingsSound = soundService.MainGUISounds["O/PSound"]
local Coinsound = soundService.MainGUISounds["O/PSound"]
local pageSound = game.SoundService.MainGUISounds.PageSound
local slideSound = soundService.MainGUISounds.SlideSound
--True/False
local settingOn = false
local coinOn = false
local slideOn = false

print('Loaded')

-------------------------------------------------------------------------------------------------

--Settings Button Function
SP.SettingsOC.MouseButton1Click:Connect(function()

	settingsSound:Play()

	if settingOn then 
		settingFrame.Visible = false
		settingOn = false
		SP.SettingsOC.text = "Open Settings"
		SP.CoinOC.Visible = true
		SP.Items.Visible = true
	else
		settingFrame.Visible = true
		settingOn = true
		SP.SettingsOC.text = "Close Settings"
		SP.CoinOC.Visible = false
		SP.Items.Visible = false
	end
end

-------------------------------------------------------------------------------------------------

--Coin Shop Function
SP.CoinOC.MouseButton1Click:Connect(function()

	Coinsound:Play()


	if coinOn then 
		coinFrame.Visible = false
		coinOn = false
		SP.CoinOC.text = "Open Coin Shop"
		SP.SettingsOC.Visible = true
		SP.Items.Visible = true
	else
		coinFrame.Visible = true
		coinOn = true
		SP.CoinOC.text = "Close Coin Shop"
		SP.SettingsOC.Visible = false
		SP.Items.Visible = false
	end
end

-------------------------------------------------------------------------------------------------

--Slide In/Out Function
slideButton.MouseButton1Click:Connect(function()

	slideSound:Play()


	if slideOn then 
		mainFrame:TweenPosition(UDim2.new(-0.19,0,0.015,0),"In","Sine",.5,true)
		slideOn=false
		mainFrame.Text = ">"
	else
		mainFrame:TweenPosition(UDim2.new(0.011,0,0.015,0),"Out","Back",1,true)
		slideOn=true
		mainFrame.Text = "<"
	end
end

(When you run this, tell me if it prints “Loaded”)

I did not see it print when I tested

1 Like

Thanks for the info, that means something errors with the Locals

Try this, also sorry that this is taking so long, I am having to Debug it:

--LOCALS

local SP = script.Parent --MOST IMPORTANT
--Frames
local coinFrame = SP.CoinsDisplayMain
local settingFrame = SP.SettingsMain
local mainFrame = SP
Buttons
local upButton = SP.Up
local downButton = SP.Down
local slideButton = SP.Slide
--Sounds
--local soundService = game.SoundService
--local settingsSound = soundService.MainGUISounds["O/PSound"]
--local Coinsound = soundService.MainGUISounds["O/PSound"]
--local pageSound = game.SoundService.MainGUISounds.PageSound
--local slideSound = soundService.MainGUISounds.SlideSound
--True/False
local settingOn = false
local coinOn = false
local slideOn = false

print('Loaded')

-------------------------------------------------------------------------------------------------

--Settings Button Function
SP.SettingsOC.MouseButton1Click:Connect(function()

	--settingsSound:Play()

	if settingOn then 
		settingFrame.Visible = false
		settingOn = false
		SP.SettingsOC.text = "Open Settings"
		SP.CoinOC.Visible = true
		SP.Items.Visible = true
	else
		settingFrame.Visible = true
		settingOn = true
		SP.SettingsOC.text = "Close Settings"
		SP.CoinOC.Visible = false
		SP.Items.Visible = false
	end
end

-------------------------------------------------------------------------------------------------

--Coin Shop Function
SP.CoinOC.MouseButton1Click:Connect(function()

	--Coinsound:Play()


	if coinOn then 
		coinFrame.Visible = false
		coinOn = false
		SP.CoinOC.text = "Open Coin Shop"
		SP.SettingsOC.Visible = true
		SP.Items.Visible = true
	else
		coinFrame.Visible = true
		coinOn = true
		SP.CoinOC.text = "Close Coin Shop"
		SP.SettingsOC.Visible = false
		SP.Items.Visible = false
	end
end

-------------------------------------------------------------------------------------------------

--Slide In/Out Function
slideButton.MouseButton1Click:Connect(function()

	--slideSound:Play()


	if slideOn then 
		mainFrame:TweenPosition(UDim2.new(-0.19,0,0.015,0),"In","Sine",.5,true)
		slideOn=false
		mainFrame.Text = ">"
	else
		mainFrame:TweenPosition(UDim2.new(0.011,0,0.015,0),"Out","Back",1,true)
		slideOn=true
		mainFrame.Text = "<"
	end
end

Sorry for taking forever, but I still didn’t see the print.

Can I see your explorer? This text will be blurred

Is there any errors at all? Also are you sure that nothing is above the locals?

What in the explorer? The gui?

I don’t see any errors that have to do with this specific issue.

Are you sure the script is not disabled and that the Gui is also not disabled? These could cause the script to not work.

Everything is visible and enabled, and the script isn’t disabled

I mean like the Explorer where the Gui is

Screenshot 2022-01-16 225042
Like this?