Hello. So I am making a quest system. And to activate a quest, you need to trigger a proximity prompt. So far, activating it works very well, but when you are done with the quest, the script does not let you turn it in.
(I apologize if the code written is in a terrible format.)
Proximity Prompt Code:
script.Parent.Triggered:Connect(function(player)
print("Activated")
local BBHfolder = player:WaitForChild("BBHQuest")
local Currency = player:WaitForChild("Currency")
local Items = player:WaitForChild("Items")
local Multiplier = player:WaitForChild("Multiplier")
print("A")
-- Available Rewards
local Chiikens = Currency:WaitForChild("Chiikens")
local Carrot = Items:WaitForChild("Carrots")
local Multiplier = player:WaitForChild("Multiplier")
print("B")
--Current
local CubeField = BBHfolder:WaitForChild("CubeField")
local SphereicalField = BBHfolder:WaitForChild("SphericalField")
local Quest = BBHfolder:WaitForChild("Quest")
local QuestActivated = BBHfolder:WaitForChild("QuestActivated")
local QuestFinished = BBHfolder:WaitForChild("QuestFinished")
print("C")
--Required
local SphericalFieldRequired = BBHfolder:WaitForChild("SphericalFieldRequired")
local CubeFieldRequired = BBHfolder:WaitForChild("CubeFieldRequired")
print("D")
--Where code just gives up
--Below is code that is supposed to run
if QuestActivated.Value == false then
print("FALSE")
--dialauge REMOTE EVENT
if Quest.Value == 0 then--If just started game
print("Quest 1 Started")
Quest.Value = 1 -- set to First Quest
SphericalFieldRequired.Value = 25 --25 chiikens needed
CubeFieldRequired.Value = 25 -- 25 chiikens needed
QuestActivated.Value = true -- TURN ON QUEST
print("E")
end
if Quest.Value == 2 then
--l
print("F")
end
if Quest.Value == 3 then
print("F2")
--l
end
elseif QuestFinished.Value == true then
if Quest.Value == 1 then
print("Finished")
QuestFinished.Value = false
SphericalFieldRequired.Value = 0
CubeFieldRequired.Value = 0
QuestActivated.Value = false
Chiikens.Value += 100
Carrot.Value += 1
print("G")
else
print("ELSE ACTIVATED")
print("H")
end
end
end)
Now, there is a boolean value that indicates if the quest has been finished or not. If the value is true, that means the quest is finished vice versa. The script below constantly checks if the quest is completed. If so, the script will turn the value to true. Indicating that the quest is finished.
Script located in StarterPlayerScripts:
local player = game.Players.LocalPlayer
local BBHfolder = player:WaitForChild("BBHQuest")
--Current
local CubeField = BBHfolder:WaitForChild("CubeField")
local SphereicalField = BBHfolder:WaitForChild("SphericalField")
local Quest = BBHfolder:WaitForChild("Quest")
local QuestActivated = BBHfolder:WaitForChild("QuestActivated")
local QuestFinished = BBHfolder:WaitForChild("QuestFinished")
--Required
local SphericalFieldRequired = BBHfolder:WaitForChild("SphericalFieldRequired")
local CubeFieldRequired = BBHfolder:WaitForChild("CubeFieldRequired")
CubeField.Changed:Connect(function()
if CubeField.Value >= CubeFieldRequired.Value then
if QuestActivated.Value == true then
print("Completed CubeField Quest")
if CubeField.Value >= CubeFieldRequired.Value and SphereicalField.Value >= SphericalFieldRequired.Value then
QuestFinished.Value = true
print(QuestFinished.Value)
end
end
end
end)
SphereicalField.Changed:Connect(function()
if SphereicalField.Value >= SphericalFieldRequired.Value then
if QuestActivated.Value == true then
print("Completed Spherical Field Quest")
if CubeField.Value >= CubeFieldRequired.Value and SphereicalField.Value >= SphericalFieldRequired.Value then
QuestFinished.Value = true
print(QuestFinished.Value)
end
end
end
end)
``