SurfaceGUI button not working

I’m currently testing SurfaceGUI to be used for a feature in my game. I’ve never used it before so I’m fairly new to it. I tries testing with it and so far it hasn’t worked. Could someone help me?

local main = script.Parent.Adornee
local event = main.Parent.war
local buttons = script.Parent.frame.buttons:GetChildren()
local notification = script.Parent.frame.notification:GetChildren()
local options = script.Parent.frame.options:GetChildren()
local msg = script.Parent.frame.error
local player = game.Players.LocalPlayer

script.Parent.frame.buttons.options.MouseButton1Click:Connect(function()
	script.Parent.frame.buttons.options.Text = "yes!"
end) ---- not even this works

for a,b in pairs(buttons) do
	print("hhh")
	if b:IsA("TextButton") then
		print("4444")
		b.MouseButton1Down:connect(function() -- Put the full location of the button where buttonnamelolidk is
	   		print("f")
			b.Text = "yes!" --- this doesnt print
		end)
	end
end
3 Likes

Do you get any error or warning messages in the Output?

1 Like

I do not. The way the surface GUI is inserted into the player might be an issues though

script.Parent:GetPropertyChangedSignal("Occupant"):connect(function()
	local Humanoid = script.Parent.Occupant
	local Char = Humanoid and Humanoid.Parent
	local Player = Char and game.Players:GetPlayerFromCharacter(Char)
	local gui = script.Parent.Parent.main.system:Clone()
	--local team = script.Parent.Parent.Parent.Parent.Parent.Parent:FindFirstChild("team")
	if Player then
		if Player.Team then
			script.Parent.Parent.main.msg.Enabled = false
			gui.Parent = Player.PlayerGui
			gui.Adornee = script.Parent.Parent.main
			gui.Enabled = true
			gui.LocalScript.Disabled = false
			repeat
				game["Run Service"].Heartbeat:wait()
			until
			not script.Parent.Occupant
			script.Parent.Parent.main.msg.Enabled = true
			gui:Destroy()
		else
			local txt = script.Parent.Parent.main.msg.Frame.TextLabel
			txt.Text = "Error: You are not authorized to use this computer!"
			wait(3)
			txt.Text = "Please sit down to use the diplomat/war system."
		end	
	end
end)

it works as intended but i dont know if its blame

2 Likes

Is the SurfaceGui inserted into the part?

No. The SurfaceGUI gets inserted into the Player’s PlayerGui

Nevermind, I realized that I had to have AlwaysOnTop set to true, which I did. Thank you for trying to help me though!

2 Likes