-
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. -
What is the issue? Include screenshots / videos if possible!
print from line 12 of code, so it’s not nil - 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.