local ProximityPromptService = game:GetService("ProximityPromptService")
local event = game:GetService("ReplicatedStorage").Events.ShowQuestionGUI
-- Detect when prompt is triggered
local function onPromptTriggered(promptObject, player)
if promptObject.Name == "QuestAPs" then
event:FireClient(player)
end
end
-- Detect when prompt hold begins
local function onPromptHoldBegan(promptObject, player)
end
-- Detect when prompt hold ends
local function onPromptHoldEnded(promptObject, player)
end
-- Connect prompt events to handling functions
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan)
ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)
I have a problem about my GUI, itās not visibleā¦ but I am updating it to true and nothing. (I tried on server side and client side).
But the problem is, the code is strange for that I mean, gui.Enabled does not work so I used RunService.Stepped:
local gui = script.Parent.Parent
local questions = {
one = {
q = "Are you allowed to TK",
correct = "No",
wrong = "Yes",
},
two = {
q = "Are you allowed to RK",
correct = "No",
wrong = "Yes",
},
three = {
q = "Who is the Premier",
correct = "ptitloup132",
wrong = "cenz28",
},
four = {
q = "What is the first Officer Rank",
correct = "Major",
wrong = "Captain",
},
five = {
q = "What is the first Senior Rank",
correct = "General of the Police",
wrong = "Marshal",
}
}
local plr = game:GetService("Players").LocalPlayer
local event = game:GetService("ReplicatedStorage").Events.ShowQuestionGUI
event.OnClientEvent:Connect(function()
local over = false
local Stepped
Stepped = game:GetService("RunService").Stepped:Connect(function()
if not over then
gui.Enabled = true
else
gui.Enabled = false
end
end)
local questionLabel = script.Parent.Question
local ran = math.random(1, 5)
local GoodAnswer = script.Parent["Answer"..math.random(1, 2)]
local BadAnswer
if GoodAnswer.Name == "Answer1" then
BadAnswer = script.Parent.Answer2
else
BadAnswer = script.Parent.Answer1
end
if ran == 1 then
questionLabel.Text = questions.one.q
GoodAnswer.Text = questions.one.correct
BadAnswer.Text = questions.one.wrong
elseif ran == 2 then
questionLabel.Text = questions.two.q
GoodAnswer.Text = questions.two.correct
BadAnswer.Text = questions.two.wrong
elseif ran == 3 then
questionLabel.Text = questions.three.q
GoodAnswer.Text = questions.three.correct
BadAnswer.Text = questions.three.wrong
elseif ran == 4 then
questionLabel.Text = questions.four.q
GoodAnswer.Text = questions.four.correct
BadAnswer.Text = questions.four.wrong
elseif ran == 5 then
questionLabel.Text = questions.five.q
GoodAnswer.Text = questions.five.correct
BadAnswer.Text = questions.five.wrong
end
for i,v in ipairs(script.Parent:GetChildren()) do
if v:IsA("TextButton") then
if v == GoodAnswer then
v.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").Events.AddAP:FireServer(3)
over = true
gui.Enabled = false
Stepped:Disconnect()
end)
elseif v == BadAnswer then
v.MouseButton1Click:Connect(function()
over = true
Stepped:Disconnect()
end)
end
end
end
end)
local gui = script.Parent.Parent
local questions = {
one = {
q = "Are you allowed to TK",
correct = "No",
wrong = "Yes",
},
two = {
q = "Are you allowed to RK",
correct = "No",
wrong = "Yes",
},
three = {
q = "Who is the Premier",
correct = "ptitloup132",
wrong = "cenz28",
},
four = {
q = "What is the first Officer Rank",
correct = "Major",
wrong = "Captain",
},
five = {
q = "What is the first Senior Rank",
correct = "General of the Police",
wrong = "Marshal",
}
}
local plr = game:GetService("Players").LocalPlayer
local event = game:GetService("ReplicatedStorage").Events.ShowQuestionGUI
event.OnClientEvent:Connect(function()
gui.Enabled = true
gui.Frame.Visible = true
local over = false
local Stepped
Stepped = game:GetService("RunService").Stepped:Connect(function()
if not over then
--gui.Enabled = true
else
--gui.Enabled = false
end
end)
local questionLabel = script.Parent.Question
local ran = math.random(1, 5)
local GoodAnswer = script.Parent["Answer"..math.random(1, 2)]
local BadAnswer
if GoodAnswer.Name == "Answer1" then
BadAnswer = script.Parent.Answer2
else
BadAnswer = script.Parent.Answer1
end
if ran == 1 then
questionLabel.Text = questions.one.q
GoodAnswer.Text = questions.one.correct
BadAnswer.Text = questions.one.wrong
elseif ran == 2 then
questionLabel.Text = questions.two.q
GoodAnswer.Text = questions.two.correct
BadAnswer.Text = questions.two.wrong
elseif ran == 3 then
questionLabel.Text = questions.three.q
GoodAnswer.Text = questions.three.correct
BadAnswer.Text = questions.three.wrong
elseif ran == 4 then
questionLabel.Text = questions.four.q
GoodAnswer.Text = questions.four.correct
BadAnswer.Text = questions.four.wrong
elseif ran == 5 then
questionLabel.Text = questions.five.q
GoodAnswer.Text = questions.five.correct
BadAnswer.Text = questions.five.wrong
end
for i,v in ipairs(script.Parent:GetChildren()) do
if v:IsA("TextButton") then
if v == GoodAnswer then
v.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").Events.AddAP:FireServer(3)
over = true
gui.Enabled = false
Stepped:Disconnect()
end)
elseif v == BadAnswer then
v.MouseButton1Click:Connect(function()
over = true
Stepped:Disconnect()
end)
end
end
end
end)