How do I check which button was pressed inside of a function?

I have one script that handles all dialogue and the dialogue choices in my game. But I’m pretty confused on how I’m supposed to check which button was pressed inside of a function. Here’s an image of how they’re arranged. The script itself is pretty simple because the entire game is based off “brain upgrades”.
image

An image which shows how the dialogue is handled inside of the script.

1 Like

What do you mean by button? The choice buttons?

1 Like

Yeah, the choice buttons. I have tried things like variables.

The best option to do is just before calling the function, you connect every single available choice buttons with a MouseButton1Click event, then when one of them fires, you know which one will fire.

What do you mean by that? Sorry, I’m an amateur at scripting.

I meant to connect every single available choice buttons with an event named MouseButton1Click.

Choice1.MouseButton1Click:Connect(function()

-- Your code here

end)

Choice2.MouseButton1Click:Connect(function()

-- Your code here

end)

This is how you determine when either of the buttons are clicked. I’d suggest firing a remote event to the server and handling the choice there.

1 Like

But how do you connect the choice buttons?

1 Like
ChoiceButton.Activated:Connect(function()
    --Do something
end)