-- QuizClientScript local ReplicatedStorage = game:GetService("ReplicatedStorage") local…
- User
-- QuizClientScript local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local player = Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui")
-- RemoteEvents local StartQuizEvent = ReplicatedStorage:WaitForChild("StartQuizEvent") local AnswerSelectedEvent = ReplicatedStorage:WaitForChild("AnswerSelectedEvent") local UpdateQuestionEvent = ReplicatedStorage:WaitForChild("UpdateQuestionEvent")
-- Reference to the NPC and its ProximityPrompt local npc = workspace:WaitForChild("Level 1") local proximityPrompt = npc:WaitForChild("HumanoidRootPart"):WaitForChild("ProximityPrompt")
-- After your other variables, add: local playerTable = workspace:WaitForChild("PlayerTable") local answerPart = playerTable:WaitForChild("Answer") local answerSurfaceGui = answerPart:WaitForChild("SurfaceGui") local answerLabel = answerSurfaceGui:WaitForChild("TextLabel")
-- GUI References local npcDialogueGui = playerGui:WaitForChild("NPCDialogue") local mainGui = playerGui:WaitForChild("MainGui") local questionFrame = mainGui:WaitForChild("QuestionFrame") local questionTextLabel = questionFrame:WaitForChild("Question")
npcDialogueGui.Enabled = false mainGui.Enabled = false
-- Buttons local acceptButton = npcDialogueGui.Frame:WaitForChild("Accept") local declineButton = npcDialogueGui.Frame:WaitForChild("Decline")
local answerButtons = { questionFrame:WaitForChild("Answer1"), questionFrame:WaitForChild("Answer2"), questionFrame:WaitForChild("Answer3"), questionFrame:WaitForChild("Answer4"), }
-- Set up answer button clicks for _, button in ipairs(answerButtons) do button.MouseButton1Click:Connect(function() print("Button clicked:", button.Text) AnswerSelectedEvent:FireServer(button.Text)
-- Disable all buttons after click for _, btn in ipairs(answerButtons) do btn.Active = false end end)end
-- Function to create typing effect local function typeText(textLabel, textToType, typingSpeed, callback) textLabel.Text = "" for i = 1, #textToType do textLabel.Text = string.sub(textToType, 1, i) wait(typingSpeed) end if callback then callback() end end
-- Update the displayQuestion function to clear the answer text: local function displayQuestion(questionData) mainGui.Enabled = true questionFrame.Visible = true
-- Clear the answer display answerLabel.Text = "" -- Hide all buttons first for _, button in ipairs(answerButtons) do button.Visible = false button.Active = false end -- Display question with typing effect typeText(questionTextLabel, questionData.question, 0.05, function() -- After typing is done, show the answer buttons for i, button in ipairs(answerButtons) do if questionData.answers[i] then button.Text = questionData.answers[i] button.Visible = true button.Active = true else button.Visible = false button.Active = false end end end) - Assistant