-
I’m trying to make a script that when a value is equal to [X], it changes a UI’s text.
-
Even if the event is fired and the value is [X], it doesn’t do anything. It’s as if the script never gets to the loop.
-
Making it only run when the UI is enabled, but it still didn’t work.
Code
-- This is client sided.
local start = game.ReplicatedStorage.StartQuest --Find our remote event
local player = game.Players.LocalPlayer
start.OnClientEvent:Connect(function()
local gui = player.PlayerGui --Find the players personal GUI
local QuestSpeechUI = gui:WaitForChild("QuestSpeechUI") --Find our quest dialogue
local yesButton = QuestSpeechUI:WaitForChild("Frame"):WaitForChild("Talk"):WaitForChild("Yes") --Find our yes button
local noButton = QuestSpeechUI:WaitForChild("Frame"):WaitForChild("Talk"):WaitForChild("No") --Find our no button
local dialogueUI = QuestSpeechUI:WaitForChild("Frame"):WaitForChild("Talk")
local questRefused = player:WaitForChild("questRefused")
QuestSpeechUI.Enabled = true --Make our UI visible
while wait() do
if questRefused.Value == false then --When our yes button is clicked
dialogueUI.Text = "Thanks for helping me out! If you complete my task, I'll reward you handsomely." --You can change this to whatever you want and it will show this text if they accept quest
yesButton.Visible = false
noButton.Visible = false
elseif questRefused.Value == true then
game.ReplicatedStorage.CancelQuest:FireServer(player)
end
end
end)