SurfaceGui Button doesn't work

So basically this surfacegui button doesn’t respond to anything even though I’m sure its correctly connected. The surfacegui is located in the startergui and the surfacegui adornee is a part in a folder.
I have no longer any idea what could be wrong.

Here is the code I am using.

local cam = workspace.CurrentCamera
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local player = game:GetService("Players").LocalPlayer
local buttondeb = false
local UserInputService = game:GetService("UserInputService")

game.StarterGui.SurfaceGui.MainFrame.TextButton.MouseButton1Click:Connect(function()
	
	game.Workspace.IntroScene["ASUS Computer Monitor Screen"].ms1:Play()
	game.StarterGui.BlackScreen.BlackFrame.Visible = true
	game.Workspace.IntroScene["Vintage 1960s"].Body.Sound:Stop()
	game.Workspace.IntroScene.Lightbulb.Bulb["Buzzing Fluorescent Light"]:Stop()
	script.Parent.Parent.Parent.LoadingScreenScript:Destroy()
	script.Parent.Parent.Parent.ChangeCameraScript:Destroy()
	script.Parent.Parent.Parent.MainMenuCameraScript:Destroy()
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	task.wait(0.3)
	game.Workspace.IntroScene["ASUS Computer Monitor Screen"]["annunciator beep"]:Play()
	repeat
		wait()
		cam.CameraType = Enum.CameraType.Custom
	until
	cam.CameraType == Enum.CameraType.Custom

	task.wait(5)

	game.Workspace.MainFacility.CardDoor.Main.bang:Play()
	task.wait(0.9)
	game.TextChatService.AmbienceScript.Parent = game.ServerScriptService
	game.TextChatService.FirstPersonBob.Parent = game.StarterPlayer.StarterCharacterScripts
	game.TextChatService.FlashlightScript.Parent = game.StarterPlayer.StarterCharacterScripts
	game.StarterGui.BlackScreen.BlackFrame.Visible = false

	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	script:Destroy()
	
end)

Big issue here is that you are using StarterGui instead of the individual PlayerGui.

local cam = workspace.CurrentCamera
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local player = game:GetService("Players").LocalPlayer
local buttondeb = false
local UserInputService = game:GetService("UserInputService")

player.PlayerGui.SurfaceGui.MainFrame.TextButton.MouseButton1Click:Connect(function()
	
	game.Workspace.IntroScene["ASUS Computer Monitor Screen"].ms1:Play()
	player.PlayerGui.BlackScreen.BlackFrame.Visible = true
	game.Workspace.IntroScene["Vintage 1960s"].Body.Sound:Stop()
	game.Workspace.IntroScene.Lightbulb.Bulb["Buzzing Fluorescent Light"]:Stop()
	script.Parent.Parent.Parent.LoadingScreenScript:Destroy()
	script.Parent.Parent.Parent.ChangeCameraScript:Destroy()
	script.Parent.Parent.Parent.MainMenuCameraScript:Destroy()
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	task.wait(0.3)
	game.Workspace.IntroScene["ASUS Computer Monitor Screen"]["annunciator beep"]:Play()
	repeat
		wait()
		cam.CameraType = Enum.CameraType.Custom
	until
	cam.CameraType == Enum.CameraType.Custom

	task.wait(5)

	game.Workspace.MainFacility.CardDoor.Main.bang:Play()
	task.wait(0.9)
	game.TextChatService.AmbienceScript.Parent = game.ServerScriptService
	game.TextChatService.FirstPersonBob.Parent = game.StarterPlayer.StarterCharacterScripts
	game.TextChatService.FlashlightScript.Parent = game.StarterPlayer.StarterCharacterScripts
	player.PlayerGui.BlackScreen.BlackFrame.Visible = false

	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	script:Destroy()
	
end)
1 Like

The button still doesn’t react, I don’t think its the problem with a script cause I have a different surface gui (not in startergui) and it works normally even without player.playergui.

Where is this local script currently stored?

Its being stored inside of the Gui Button, basically “Game.StarterGui.SurfaceGui.MainFrame.TextButton.LocalScript”

Try this maybe? Edit: Let me know if TextButton Clicked is not printing.

local cam = workspace.CurrentCamera
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local player = game:GetService("Players").LocalPlayer
local buttondeb = false
local UserInputService = game:GetService("UserInputService")

script.Parent.MouseButton1Click:Connect(function()
	print("TextButton Clicked") -- Debug
	game.Workspace.IntroScene["ASUS Computer Monitor Screen"].ms1:Play()
	script.Parent.Parent.Parent.Parent.BlackScreen.BlackFrame.Visible = true
	game.Workspace.IntroScene["Vintage 1960s"].Body.Sound:Stop()
	game.Workspace.IntroScene.Lightbulb.Bulb["Buzzing Fluorescent Light"]:Stop()
	script.Parent.Parent.Parent.LoadingScreenScript:Destroy()
	script.Parent.Parent.Parent.ChangeCameraScript:Destroy()
	script.Parent.Parent.Parent.MainMenuCameraScript:Destroy()
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	task.wait(0.3)
	game.Workspace.IntroScene["ASUS Computer Monitor Screen"]["annunciator beep"]:Play()
	repeat
		wait()
		cam.CameraType = Enum.CameraType.Custom
	until
	cam.CameraType == Enum.CameraType.Custom

	task.wait(5)

	game.Workspace.MainFacility.CardDoor.Main.bang:Play()
	task.wait(0.9)
	game.TextChatService.AmbienceScript.Parent = game.ServerScriptService
	game.TextChatService.FirstPersonBob.Parent = game.StarterPlayer.StarterCharacterScripts
	game.TextChatService.FlashlightScript.Parent = game.StarterPlayer.StarterCharacterScripts
	script.Parent.Parent.Parent.Parent.BlackScreen.BlackFrame.Visible = false

	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserInputService.MouseIconEnabled = false
	script:Destroy()
	
end)

Nothing is printing, nothing changes in the output