Quest system constantly looping

  1. What do you want to achieve?
    Im making a quest system

  2. What is the issue?
    but this script is on a loop idk if theres a way to make it loop without the task.wait()

  3. What solutions have you tried so far?
    Havent found 1 yet

while task.wait(0.1) do
	local Module = require(game.ReplicatedStorage.Quest)
	local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
	if plr.Quests[script.Parent.Name].Min.Value >=plr.Quests[script.Parent.Name].Max.Value then
		plr.Quests[script.Parent.Name].Min.Value = plr.Quests[script.Parent.Name].Max.Value
		if plr.Quests[script.Parent.Name].Completed.Value == false then
			script.Parent.CompleteButton.Visible = true
			if script.Parent.CompleteButton.Visible == true then
				plr.PlayerGui.ScreenButtons:WaitForChild("Buttons"):WaitForChild("Quests"):WaitForChild("Info").Visible = true
			end
			script.Parent.Bars.TextLabel.Text = "%100"
		else
			script.Parent.CompleteButton.Visible = false
			script.Parent.Bars.TextLabel.Text = "%100"
			script.Parent.Rarity.Text = "Completed!"
			script.Parent.CColor.BackgroundColor3 = game.ReplicatedStorage.Pets.Rarities2.Completed.Color.Value
			script.Parent.Bars.Visible = false
		end
	else
		script.Parent.CompleteButton.Visible = false
	end
end
1 Like

If the value’s you are checking are actual instances, you can use the .Changed() Event to queue when the player has inputted one of the requirements. Then, you could check if what you need.

plr.Quest[script.Parent.Name].Min.Changed:Connect(function(newValue)
     ...
end)

local plr = script.Parent.Parent.Parent.Parent.Parent.Parent

plr.Quest[script.Parent.Name].Min.Changed:Connect(function(newValue)
	if plr.Quests[script.Parent.Name].Min.Value >=plr.Quests[script.Parent.Name].Max.Value then
		plr.Quests[script.Parent.Name].Min.Value = plr.Quests[script.Parent.Name].Max.Value
		if plr.Quests[script.Parent.Name].Completed.Value == false then
			script.Parent.CompleteButton.Visible = true
			if script.Parent.CompleteButton.Visible == true then
				plr.PlayerGui.ScreenButtons:WaitForChild("Buttons"):WaitForChild("Frame"):WaitForChild("Buttons"):WaitForChild("Quests"):WaitForChild("Info").Visible = true
			end
			script.Parent.Bars.TextLabel.Text = "%100"
		else
			script.Parent.CompleteButton.Visible = false
			script.Parent.Bars.TextLabel.Text = "%100"
			script.Parent.Rarity.Text = "Completed!"
			script.Parent.CColor.BackgroundColor3 = game.ReplicatedStorage.Pets.Rarities2.Completed.Color.Value
			script.Parent.Bars.Visible = false
		end
	else
		script.Parent.CompleteButton.Visible = false
	end
end)