I am making an application system for my game. Everything works properly, but when I click the NextButton, nothing happens and things don’t print.
Explorer
Code (This is the first ever application system I’m working on. Sorry if code is sloppy.)
local PlayerGui = game.Players.LocalPlayer.PlayerGui
local TransparentLayer = PlayerGui:WaitForChild("Application")["Base"]["Transparent Layer"]
local IntroductionTemplate = TransparentLayer["Introduction Template"]
local ReadyButton = IntroductionTemplate:FindFirstChild("ReadyButton")
local NextButton = TransparentLayer["Question Template"]["NextButton"]
IntroductionTemplate.Visible = true
local SavedAnswers = {}
local TimeLimit = 300
local NotedTimeLimit = 300
local Functions = {}
local Trello = {}
function Functions:BaseFunction(QuestionNum, Question)
local QuestionString = "Q"..QuestionNum..". "..Question
local QuestionTemplate = TransparentLayer["Question Template"]
if IntroductionTemplate then
local HidingPos = UDim2.new(2,0,0,0)
local TargetPos = UDim2.new(0.012,0,0,0)
IntroductionTemplate:TweenPosition(HidingPos, "Out", "Quint", 1)
repeat wait() until IntroductionTemplate.Position == HidingPos
IntroductionTemplate:Destroy()
local QuestionBox = QuestionTemplate.QuestionBox
QuestionBox.Text = QuestionString
QuestionTemplate.Visible = true
QuestionTemplate:TweenPosition(TargetPos, "Out", "Quint", 1)
end
if TransparentLayer:FindFirstChild("Question Template") then
local Question = TransparentLayer:FindFirstChild("Question Template")
local HidingPos = UDim2.new(2,0,0,0)
local TargetPos = UDim2.new(0.012,0,0,0)
Question:TweenPosition(HidingPos, "Out", "Quint", 1)
repeat wait() until Question.Position == HidingPos
local QuestionBox = Question.QuestionBox
QuestionBox.Text = QuestionString
Question.Visible = true
Question:TweenPosition(TargetPos, "Out", "Quint", 1)
end
end
function OnNBClick()
print("got to the clicked function") -- Not printing
local Times = 0
if Times == 0 then
Times = Times + 1
Functions:BaseFunction("2", "Why do you choose to work at Reiné over other companies?")
elseif Times == 1 then
Times = Times + 1
Functions:BaseFunction("3", "Why do you feel like you should be accepted over other applicants & what special abilities do you possess?")
elseif Times == 2 then
Times = Times + 1
Functions:BaseFunction("4", 'Correct this sentence: Hay welcome to rénay cafwe. Im gladd too be takinq youre ordier todeay howw may i helpp!')
end
end
function Trello:sendResults()
end
if TransparentLayer:FindFirstChild("Introduction Template") then
local IntroductionTemplate = TransparentLayer:FindFirstChild("Introduction Template")
local ReadyButton = IntroductionTemplate:FindFirstChild("ReadyButton")
ReadyButton.MouseButton1Click:Connect(function()
Functions:BaseFunction("1", "If you were to greet a customer at the cafe, what would be your greeting?")
end)
end
NextButton.MouseButton1Click:Connect(OnNBClick) -- Supposed to connect.
I’ve tried both of your ideas, none of them worked. I added a return at the end of my first if-statement because they both ran. Now only one of them runs, but I still have the same problem.
I’ve also tried prints, but the only part of the code that runs properly is the first if-statement. I already know that runs properly so there’s no point for print statements.
local PlayerGui = game.Players.LocalPlayer.PlayerGui
local TransparentLayer = PlayerGui:WaitForChild("Application")["Base"]["Transparent Layer"]
local IntroductionTemplate = TransparentLayer["Introduction Template"]
local ReadyButton = IntroductionTemplate:FindFirstChild("ReadyButton")
local NextButton = TransparentLayer["Question Template"]["NextButton"]
IntroductionTemplate.Visible = true
local SavedAnswers = {}
local TimeLimit = 300
local NotedTimeLimit = 300
local function BaseFunction(QuestionNum, Question)
local QuestionString = "Q"..QuestionNum..". "..Question
local QuestionTemplate = TransparentLayer["Question Template"]
if IntroductionTemplate then
local HidingPos = UDim2.new(2,0,0,0)
local TargetPos = UDim2.new(0.012,0,0,0)
IntroductionTemplate:TweenPosition(HidingPos, "Out", "Quint", 1)
repeat wait() until IntroductionTemplate.Position == HidingPos
IntroductionTemplate:Destroy()
local QuestionBox = QuestionTemplate.QuestionBox
QuestionBox.Text = QuestionString
QuestionTemplate.Visible = true
QuestionTemplate:TweenPosition(TargetPos, "Out", "Quint", 1)
return
end
if TransparentLayer:FindFirstChild("Question Template") then
local Question = TransparentLayer:FindFirstChild("Question Template")
local HidingPos = UDim2.new(2,0,0,0)
local TargetPos = UDim2.new(0.012,0,0,0)
Question:TweenPosition(HidingPos, "Out", "Quint", 1)
repeat wait() until Question.Position == HidingPos
local QuestionBox = Question.QuestionBox
QuestionBox.Text = QuestionString
Question.Visible = true
Question:TweenPosition(TargetPos, "Out", "Quint", 1)
end
end
function OnNBClick()
print("got to the clicked function")
local Times = 0
if Times == 0 then
Times = Times + 1
BaseFunction("2", "Why do you choose to work at Reiné over other companies?")
elseif Times == 1 then
Times = Times + 1
BaseFunction("3", "Why do you feel like you should be accepted over other applicants & what special abilities do you possess?")
elseif Times == 2 then
Times = Times + 1
BaseFunction("4", 'Correct this sentence: Hay welcome to rénay cafwe. Im gladd too be takinq youre ordier todeay howw may i helpp!')
end
end
function sendTrelloResults()
end
if TransparentLayer:FindFirstChild("Introduction Template") then
local IntroductionTemplate = TransparentLayer:FindFirstChild("Introduction Template")
local ReadyButton = IntroductionTemplate:FindFirstChild("ReadyButton")
ReadyButton.MouseButton1Click:Connect(function()
BaseFunction("1", "If you were to greet a customer at the cafe, what would be your greeting?")
end)
end
NextButton.MouseButton1Click:Connect(OnNBClick)
NextButton.MouseButton1Click:Connect(function()
print("got to the clicked function")
local Times = 0
if Times == 0 then
Times = Times + 1
BaseFunction("2", "Why do you choose to work at Reiné over other companies?")
elseif Times == 1 then
Times = Times + 1
BaseFunction("3", "Why do you feel like you should be accepted over other applicants & what special abilities do you possess?")
elseif Times == 2 then
Times = Times + 1
BaseFunction("4", 'Correct this sentence: Hay welcome to rénay cafwe. Im gladd too be takinq youre ordier todeay howw may i helpp!')
end
end)
I see, I thought there might be another frame or something behind it; I guess I’m too used to doing that for my own UI.
I mean, if everything runs up to that event, but the event itself doesn’t call, then you should try the event in another script to see if it is an internal issue. Otherwise it has to be something stopping the event from being defined; i.e., something is stopping your code from running at some point.