Button not working

My button is not working I don’t understand why

Print line is not displaying at all

Here’s the code of the button

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

local BuyButton = script.Parent.Buy

BuyButton.MouseButton1Click:Connect(function()
	print("BUY BUTTON HAS BEEN CLICKED")
end)

Here’s the structure of the overall button

Can you put a print function outside the event so we can confirm it runs

I already did that and it worked the print outside means that the localscript is running clearly

Im noticing the console has some errors, maybe one of them is about this script?

No the Animate has nothing to do with the localscript

I meant maybe there’s more in the console than the animate

I’m asking GPT and GPT tells me about ClipDescendants might try this

Are you sure you are allowed to nest Button instances like that? It seems like a bad idea to me

What do you mean of course you are allowed why wouldn’t I be ?

It wouldnt really matter now would it

Bro how much is this guy writing…?
Im scared

ahahahhahahha I have no idea my G

I don’t understand why it’s not working my localscript is in a ScreenGui, my buttons seems to be active I don’t know if it’s the nesting of multiple layout of buttons

Maybe it does really matter and all the nesting messed everything up

There isn’t a lot more information that you’ve provided us since the script is doing what it’s exactly doing; The BuyButton Event is just detecting when the Button is being pressed to run that print statement & that’s the end of the function

What are you wanting to do after clicking the button?

  • Make it a one-and-done event?
  • Make it have the ability to purchase said “thing” multiple times?

If you’re choosing 1 of those 2, you need to first check for conditional statements (Mainly server-sided) for buying that said “thing” in the game, and next change properties according to the local GUI (Changing Button + Text Color after purchase, displaying result of purchase, etc)

You have to finish off the rest on what you’d wanna accomplish with said Event (After clicking the button), if you’d like to take some suggestions you can add another IntValue that’ll display the game’s custom currency that it uses where you have your ExpPlayer script to create the leaderstats

I’d also recommend looking more into how RemoteEvents + RemoteFunctions works if you want to securely check your conditional statements via replication

image

-- Your LocalScript
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local RemoteFunction = RS:WaitForChild("RemoteFunction") -- You can name this to whatever you want
local LocalPlayer = Players.LocalPlayer

local BuyButton = script.Parent.Buy
local CostAmount = 0 -- Change this to however much it costs

BuyButton.MouseButton1Click:Connect(function()
    local Result = RemoteFunction:InvokeServer(CostAmount)
    print("BUY BUTTON HAS BEEN CLICKED")

    if Result == "Success" then
        print("Worked!")
    elseif Result == "Not Enough"
        print("Not Enough Currency!")
    elseif Result "Failure" then
        warn("Something weird happened!")
    end
end)
-- Different Script
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local RemoteFunction = RS:WaitForChild("RemoteFunction") -- You can name this to whatever you want

local function Purchase(Plr, CostAmount)
    local leaderstats = Plr:FindFirstChild("leaderstats")

    if not leaderstats then return end

    local Currency = leaderstats:WaitForChild("IntValueHere")
    local CostRequirement = Currency.Value >= CostAmount

    if CostRequirement  == true then
        Currency.Value -= CostAmount
        return "Success"
    elseif CostRequirement == false then
        return "Not Enough"
    else
        return "Failure"
    end
end

RemoteFunction.OnServerInvoke = Purchase

No it’s not the nesting I found the solution to the problem

Bro im going to put butter on all your toast

Huh what lol what do you mean ?

I mostly figured it might not be possible because the straight-forward implementation of a button input would be checking if the user clicked within the bounds of the active button. In addition to this, the buttons would be presumably checked parent-to-child, so the parent button would always take priority. It does work this way in other frameworks (HTML I think? I’m not really sure where I got it from).

Well anyway, I said it’s a bad idea because I also consider this to be bad UI design. I can’t think of a situation where nested buttons are needed or would look better / be more flexible than a different design. Do you have any examples where using nested buttons is a good design choice? This is another reason why I thought it might not be allowed