i would like to achieve making a button that can ask questions every time its clicked.
Could you provide more details, your goal is not very clear.
If you want to ask “questions”, you can edit a TextLabel to a question. Maybe a random question from a list of questions (array) and you want buttons.
If the above is what you want to achieve you can first make an array with a list of questions like this
local questions = {
"Are you a veteran or a newbie?",
"Are you good at obbies?",
"What is Roblox?"
}
Then use math.random
to pick a random question from the array of questions and set it.
You should replace YourTextLabelObjectHere
with your actual TextLabel instance.
local selectedquestion = questions[math.random(1,#questions)]
YourTextLabelObjectHere.Text = selectedquestion
Then maybe link click events to your “answer” buttons.
YourTextButton.MouseButton1Click:Connect(function()
print("Button Clicked!")
end)
well i would like to a make a Questionare button you know would you rather do this or that every time someone touches or clicks on the button
something like the game “Neighbors”
Could you provide screenshot example so I can understand better what you’re trying to achieve?
So you want to ask questions…?
Do you want like anything else? (The player’s response, GUI Buttons?)
Assuming you only want to ask questions upon the press of a button you can do this:
First you want to add a ClickDetector
to the object you want to detect for clicks.
Then in a Script
under the object, you can do it like this:
local clickdetector = script.Parent.ClickDetector
local chat = game:GetService("Chat")
local questions = {
"Under what name was Roblox first created?",
"Who owns Roblox?",
"When was Roblox released?",
"When was the last Roblox egg hunt?",
"What year did Roblox introduce UGC Limiteds to allow user-generated content?"
-- Add more questions
}
clickdetector.MouseClick:Connect(function()
local selectedQuestion = questions[math.random(1, #questions)]
chat:Chat(script.Parent, selectedQuestion)
end)
Result: