Custom Spectator System Issue:

Hello! How are you?

I am currently having issues making my custom spectator system work properly… At first, in order to see the spectator mode, you need to press the first GUI button that disables the visibility of other unnecessary UIs + Another small version of the button is red to represent going back to the main menu.

However, when trying to test it out, the go-back button called backFrame does not work as expected. I tried reviewing and I don’t know what is the problem…

local backFrame = game.StarterGui.MainGui.MenuFrame.SpectateButton.BackSpectateButton

backFrame.MouseButton1Click:Connect(function()
	print("Please wait...")
	wait(5)
	game.StarterGui.MainGui.MenuFrame.SpectateButton.ScrollingFrame.Visible = false
	game.StarterGui.MainGui.MenuFrame.MainFrame.Visible = true
	game.StarterGui.MainGui.MenuFrame.TutorialButton.Visible = true
	game.StarterGui.MainGui.MenuFrame.SpectateButton.BackSpectateButton.Visible = false
end)

If anyone can help me with this, I would really appreciate it. Thank you!

You use StarterGui instead of PlayerGui. Assuming this is a local script, and it is under the backFrame, it would look like this:

local backFrame = script.Parent
local plr = game.Players.LocalPlayer

backFrame.MouseButton1Click:Connect(function()
	print("Please wait...")
	wait(5)
	plr.PlayerGui.MainGui.MenuFrame.SpectateButton.ScrollingFrame.Visible = false
	plr.PlayerGui.MainGui.MenuFrame.MainFrame.Visible = true
	plr.PlayerGui.MainGui.MenuFrame.TutorialButton.Visible = true
	plr.PlayerGui.MainGui.MenuFrame.SpectateButton.BackSpectateButton.Visible = false
end)
1 Like

When someone connects to the game, everything in StarterGui is cloned into PlayerGui. You’re basically just editing the original copy. I’d suggest placing the script inside of the Gui your frames are placed in so it’s easily accessible to the script.

Example hierarchy:

PlayerGui 
     -> MainGui
          -> LocalScript
          -> MenuFrame