Is there something wrong in this if statement?

I try to make this mission script but why does this not work? (see script)

plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Changed:Connect(function()
		
		print(plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Value, plr.Missions:FindFirstChild(mission.Value).ChosenMissionAmount.Value)
		
		if plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Value == plr.Missions:FindFirstChild(mission.Value).ChosenMissionAmount.Value then
			print("YES")
			plr.GoofCredits.Value += 500
			plr.CurrentXP.Value += 250
			plrmissionsfolder:Destroy()
			newmissionframe:Destroy()
			
			else
			
			print("NO")
		end
	end)


image

So this is confusing, but try that and tell what it prints:

plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Changed:Connect(function()
		
		print(plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Value, plr.Missions:FindFirstChild(mission.Value).ChosenMissionAmount.Value)
		
		if plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Value == plr.Missions:FindFirstChild(mission.Value).ChosenMissionAmount.Value then
			print("YES")
			plr.GoofCredits.Value += 500
			plr.CurrentXP.Value += 250
			plrmissionsfolder:Destroy()
			newmissionframe:Destroy()
			
		else
		    print(plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Value, plr.Missions:FindFirstChild(mission.Value).ChosenMissionAmount.Value)
			print("NO")
		end
	end)

What are the class names of OwnProgressValue and ChosenMissionAmount?
Ex:
image

Maybe run this code to print it out.

local selectedMission = plr.Missions:FindFirstChild(mission.Value)
print(selectedMission.OwnProgressValue.ClassName)
print(selectedMission.ChosenProgressValue.ClassName)

Good question, but I dont think that this is the problem because it would print an error if its not the same Value Class

image

1 Like

Along with what everyone else said, you do know that .Changed returns the new value right? There’s no need for these long winded references.

Code:

plr.Missions:FindFirstChild(mission.Value).OwnProgressValue.Changed:Connect(function(newProgress)
	print(type(newProgress))

	if newProgress == plr.Missions:FindFirstChild(mission.Value).ChosenMissionAmount.Value then
		print("YES")
		plr.GoofCredits.Value += 500
		plr.CurrentXP.Value += 250
		plrmissionsfolder:Destroy()
		newmissionframe:Destroy()
	else
		print("NO")
	end
end)

Tell me what this prints.

nvm, i fixed it. it was a stringvalueđź’€

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