SurfaceGUI TextButton Clicking issue

  1. What do you want to achieve? Keep it simple and clear!
    So kinda topic explains everything. I can’t click textButton in surfaceGUI. It just doesn’t fire mouseButton1Click.
  2. What is the issue? Include screenshots / videos if possible!
    image
    print from line 12 of code, so it’s not nil
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Well i have no possible idea why it no work

Code:

local CollectionService = game:GetService("CollectionService")
local ClientFunctions = require(game:GetService("ReplicatedStorage").ClientFunctions)
local player = game:GetService("Players").LocalPlayer
for _,upgrade in pairs(workspace:GetDescendants()) do
	if upgrade:IsA("Frame") then
		if CollectionService:HasTag(upgrade, "Upgrade") then
			local BackButton = upgrade.Parent.Parent.Parent.UpgradeFrame.BackButton
			upgrade.UpgradeFire.MouseButton1Click:Connect(function()
				ClientFunctions:UpdateUpgradeFrame(player, upgrade, "Upgrade")
			end)
BackButton.Parent:GetAttributeChangedSignal("currentUpgrade"):Connect(function()
			print(BackButton.Parent:GetAttribute("currentUpgrade"))
				BackButton.MouseButton1Click:Connect(function()
				if BackButton.Parent:GetAttribute("currentUpgrade") ~= "nil" then
					ClientFunctions:UpdateUpgradeFrame(player, upgrade, "Return")
				end
				end)
				end)
		elseif CollectionService:HasTag(upgrade, "Unlockable") then
			upgrade.UpgradeFire.MouseButton1Click:Connect(function()
				ClientFunctions:UpdateUpgradeFrame(player, upgrade, "Unlockable")
			end)
			upgrade.Parent.Parent.Parent.UpgradeFrame.BackButton.MouseButton1Click:Connect(function()
				ClientFunctions:UpdateUpgradeFrame(player, upgrade, "Upgrade")
			end)
		end
		end
end

Please NOTE that code is in StarterPlayerScript so it should run. Also all text buttons are active. Also part which don’t work is BackButton, upgrade.UpgradeFire works perfectly.

Topic Bump (30 letterssssssssss)

11 days after i still don’t have any idea on how to fix this

BackButton.Parent:GetAttributeChangedSignal("currentUpgrade"):Connect(function()
	print(BackButton.Parent:GetAttribute("currentUpgrade"))
	BackButton.MouseButton1Click:Connect(function()
		if BackButton.Parent:GetAttribute("currentUpgrade") ~= "nil" then
			ClientFunctions:UpdateUpgradeFrame(player, upgrade, "Return")
		end
	end)
end)

So, you are telling the script to make a new MouseButton1Click event when the attribute is changed. This is bad practice because if, let’s say, the attribute is changed 20 times. That means it will create 20 events of it. This is pretty bad for the memory of the server.

Also, what’s the point of having the GetPropertyAttributeChanged? Can’t you just remove it and it will still work since it will just check if the Attribute is not nil.

That’s some of my checks and tests. Though i figured problem. That was Union Issue. I used negative part to make hole for surfaceGUI and now just made 4 parts unioned. With negative part i had an invisible collidable wedge(glitch of union idk) right in front of button. So that caused i can’t click button

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