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

Help? If order = 1, wait until button is hit

		local ord = script.Parent.Parent.Order.Value
		local reg = game.Workspace.Register1
		
		local pepp = reg.Pepperoni.Hit.Value
		local chee = reg.Cheese.Hit.Value
		local saus = reg.Sausage.Hit.Value
		local moun = reg.MountainDew.Hit.Value		
		
		local g = game.Lighting.Storage.g

		print (ord)
		




		if ord == 1 then repeat wait() until
			pepp == 1
			if pepp == 1 then g = reg.Pepperoni.Pepperoni
			elseif pepp ~= 1 then return end
			
			
			if ord == 2  then repeat wait() until
				chee == 1
				if chee == 1 then g = reg.Cheese.Cheese
				elseif chee ~= 1 then return end	
				
				
				if ord == 3 then repeat wait() until
					saus == 1
					if saus == 1 then g = reg.Sausage.Sausage	
					elseif saus ~= 1 then return end
					
					
					if ord == 4 then repeat wait() until
						moun == 1
						if moun == 1 then g = reg.Pepperoni.Pepperoni
						elseif moun ~= 1 then return end

If anyone could help, that would be great. Thank you.

Its stressing me out because ive tried so many different things and everything I have tried so far hasn't worked.

To try help you understand:

	If the order = 1, wait until Pepperoni button is hit

	IF the button IS clicked,    g  =  Pepperoni

	if the button isnt clicked, continue waiting?

	else-if the order = 2, then (the same as above)

3 comments

0

Any errors in output?

0

No. Somehow. It either skips it or doesn't run it due to some error, but no error appears..

0

Did you want the e.g. 19 and 20th lines to be inside the loop in the 17th, so they run until the pepp is 1?

1 answer

First, you have to understand how loops work (here's the official article for loops)

repeat --The beginning of the loop
	--The code that runs every time
until x==y --The condition that stops the loop

The problem with your code (if I understood correctly what you wanted to do) is that there's nothing inside your loop, and you wrote everything in the same line (this is not actually a problem, just helps you understand it better).

So, you have to make all of them like this (17-20 lines selected for example):

if ord == 1 then
	repeat --Start of the loop
		wait()
		if pepp == 1 then 
			g = reg.Pepperoni.Pepperoni
		elseif pepp ~= 1 then
			return
		end
	until pepp == 1 --Condition to stop
end

Please try to understand it before you try to write a code

Let me know if I helped

2 comments

0

Hi. Thank you so much. So ive put the script in properly, and made the other orders the same.. But for some strange reason, it doesnt seem to detect when Hit.Value = 1..

0

Ok so I put Hit.Value as 1 to see if that would fix anything. And no. The script just doesnt seem to detect it. Does it have anything to do with the ClassName? (StringValue) I doubt it.

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