Proximity Prompt Script Not Working

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)

``

Why are you doing:

questActivated.Value

?
It’s a bolean, just do:

if not questActivated then

Does “D” print?

Yes. A, B, C, and D all print. Below the D is where nothing works

Have you tried what I said?

It’s clearly a bool object…

my bad, its just a bool object, not a boolean

Yes. There is no difference. They both mean pretty much the same thing

1 Like

Also, did you trigger the proximity prompt after you finished the quest??

1 Like

You have to trigger the proximity prompt in order for you to turn in the quest.

Alright people, my life is a lie. Just had to change the if statement in the “Quest Finished” thingy. I am not marking this as an answer though. DeDe_4242 gave me the goofy idea to change the LAST if statement. Dede only helped for the FIRST if statement. Instead of elseif QuestFinished.Value == true then I did elseif QuestFinished then.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.