Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

--- How to make script wait until criteria is met?

Ive spent ages on this and made lots of errors.. But I dont know why it failed.

The part about pepp/chee/saus/moun isnt working.

I want it to change g when the hit value for those, equals 1 and the order value equals 1,2,3 or 4.

The hit value changes when I hit one of the 4 buttons.

function OnClick(hit)
	print("1")
	if hit == nil then wait(1) return end

	local r = script.Parent.Parent.Say
	
	if r ~= nil then

		script.Parent.Parent.Name = r.Value
		mode = 1
	end
	
		if script.Parent.Parent.Name == r.Value then
		print("2")		
		
		--if de == false then
		--	de = true	
			
		local ord = script.Parent.Parent.Order.Value
		local reg = game.Workspace.Register1 --or game.Workspace.Register2 or game.Workspace.Register3
		



	local pepp = reg.Pepperoni.Hit.Value
	local chee = reg.Cheese.Hit.Value
	local saus = reg.Sausage.Hit.Value
	local moun = reg.MountainDew.Hit.Value
		

--[[		while pepp or chee or saus or moun == "1" do
			wait(1)
			print("3")
			if pepp == "1" and ord == "1" then g = reg.Pepperoni.Pepperoni end
			if chee == "1" and ord == "2" then g = reg.Cheese.Cheese end
			if saus == "1" and ord == "3" then g = reg.Sausage.Sausage end
			if moun == "1" and ord == "4" then g = reg.MountainDew.MountainDew end
			end]]

	
		
--[[		repeat
if pepp == 0 and ord == 1 then repeat wait() until pepp == 1
			elseif chee == 0 and ord == 2 then repeat wait() until chee == 1
				elseif saus == 0 and ord == 3 then repeat wait() until saus == 1
					elseif moun == 0 and ord == 4 then repeat wait() until moun == 1
			end	
		until pepp or chee or saus or moun == 1

--[[	repeat

	if pepp == 1 and ord == "1" then g = reg.Pepperoni.Pepperoni
		elseif chee == 1 and ord == "2" then g = reg.Cheese.Cheese
		elseif saus == 1 and ord == "3" then g = reg.Sausage.Sausage
			elseif moun == 1 and ord == "4" then g = reg.MountainDew.MountainDew
				
	end
			print("5")
				
				until pepp or chee or saus or moun == 1 and ord == ('1,4')]]
						
		print("4...", r.Value)	
		

		repeat wait() until pepp or chee or saus or moun ~= 0
		if pepp == "1" and ord == "1" then g = reg.Pepperoni.Pepperoni
		elseif chee == "1" and ord == "2" then g = reg.Cheese.Cheese
		elseif saus == "1" and ord == "3" then g = reg.Sausage.Sausage
		elseif moun == "1" and ord == "4" then g = reg.MountainDew.MountainDew
		
		
			
				
				--g = 
		if g ~= nil then					
			print (g)	

So many errors.. and the solution is probably so simple.

If anyone has any solution, that would be great.

1 answer

while pepp or chee or saus or moun == 1 do

why not change this line to:

while pepp == 1 or chee == 1 or saus == 1 or moun == 1 do

One thing, maybe you're too lazy to do this. Second thing, you can't use obj or obj2 or obj3 == certainObj because that only applies to real life.

3 comments

0

I don't know why but I never thought of that. But listen, I've been trying everything and it made no sense why it wasn't working. I'm gonna try that later. Thanks.

0

Litterally everything else was fine, its just getting that g to change depending on certain things which wasn't working. I'm exhausted honestly.

0

But why did you think I was lazy? You can see I tried a lot of different things to get it to work (And more). Anyways.. Ill accept your answer once I try it out and see if I get it to work.

This discussion is preserved as it was. New answers, comments, and votes are closed.