SurfaceGui TextButtons not working on the client

Title explains everything, I can’t get my TextButtons to work…

LocalScript in StarterPlayerScripts:

local clientModules: Folder = game:GetService("ReplicatedStorage"):WaitForChild("ClientModules")

local areasModule: ModuleScript = clientModules:WaitForChild("Areas") :: ModuleScript
local connectSurfaceGuiModule: ModuleScript = areasModule:WaitForChild("ConnectSurfaceGui") :: ModuleScript

local areas = require(areasModule)
local connectSurfaceGui = require(connectSurfaceGuiModule)

local areaBarriers: Folder = workspace:WaitForChild("World"):WaitForChild("AreaBarriers")
for _, area in areas do
	if not areaBarriers:FindFirstChild(area["name"]) then
		areaBarriers:WaitForChild(area["name"])
		
		for _, v in areaBarriers:FindFirstChild(area["name"]):GetDescendants() do
			if v:IsA("SurfaceGui") then
				connectSurfaceGui.connectSurfaceGui(v)
			end
		end
	end
end

ModuleScript (connects every SurfaceGui):

local players: Players = game:GetService("Players")

local player: Player = players.LocalPlayer or players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local playerGui: PlayerGui?

local connectSurfaceGui = {}

function connectSurfaceGui.connectSurfaceGui(surfaceGui: SurfaceGui)
	playerGui = player:FindFirstChildOfClass("PlayerGui")
	if not playerGui then return end
	
	surfaceGui.Adornee = surfaceGui.Parent
	surfaceGui.Parent = playerGui
end

return connectSurfaceGui

I’ve checked and every SurfaceGui has it’s Adornee property set to the BasePart it corresponds to. Every SurfaceGui is parented to the player’s PlayerGui.

3 Likes

Try enabling the Always on Top property, It could be that! Otherwise, I will checkout one of my recent projects where I had the same issue. :ok_hand:

2 Likes

This seems to work! But it kind of bugs me that the SurfaceGui is visible through everything…

1 Like

Oh yeah right. You must be using mesh parts, right? If it’s a normal part, your UI should work fine without that property.

2 Likes

I’d wish…
image

1 Like

Fixed the issue by recreating the part, I don’t know what was the problem.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.