generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do I break this "while true do" statement?

Previous Thread :: Next Thread 
poppyseed101 is not online. poppyseed101
Joined: 25 Sep 2010
Total Posts: 78
21 Feb 2016 03:45 PM
Actual script v

switch = script.Parent.Switch
toggle = false

function lightswitch()
toggle = not toggle
if not toggle then
while true do
script.Parent.Front1.Material = Enum.Material.Neon
script.Parent.FMiddle1.Material = Enum.Material.Neon
script.Parent.MMiddle1.Material = Enum.Material.Neon
script.Parent.RMiddle1.Material = Enum.Material.Neon
script.Parent.Rear1.Material = Enum.Material.Neon
script.Parent.Front2.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.Rear2.Material = Enum.Material.SmoothPlastic
wait(0.5)
script.Parent.Front1.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.Rear1.Material = Enum.Material.SmoothPlastic
script.Parent.Front2.Material = Enum.Material.Neon
script.Parent.FMiddle2.Material = Enum.Material.Neon
script.Parent.MMiddle2.Material = Enum.Material.Neon
script.Parent.RMiddle2.Material = Enum.Material.Neon
script.Parent.Rear2.Material = Enum.Material.Neon
wait(0.5)
end
else
script.Parent.Front1.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.Rear1.Material = Enum.Material.SmoothPlastic
script.Parent.Front2.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.Rear2.Material = Enum.Material.SmoothPlastic
end
end

switch.ClickDetector.MouseClick:connect(lightswitch)


I need to break the loop of in the first block upon toggling the switch a second time.

Thanks in advance!
Report Abuse
crashproof is not online. crashproof
Joined: 18 May 2013
Total Posts: 250
21 Feb 2016 03:47 PM
set the function and toggle to local


yes my siggy
Report Abuse
hboogy101 is not online. hboogy101
Joined: 10 Apr 2011
Total Posts: 1392
21 Feb 2016 03:47 PM
just use repeat and if statements..
Report Abuse
poppyseed101 is not online. poppyseed101
Joined: 25 Sep 2010
Total Posts: 78
21 Feb 2016 03:48 PM
Elaborate please.

Not very frequent scripter, and I don't know how to do many things.
Report Abuse
poppyseed101 is not online. poppyseed101
Joined: 25 Sep 2010
Total Posts: 78
21 Feb 2016 03:52 PM
How does one "toggle to local"?
Report Abuse
crashproof is not online. crashproof
Joined: 18 May 2013
Total Posts: 250
21 Feb 2016 03:53 PM
wow u obviously cant script
so set x to the y of click detector as your x is * to z and y.


yes my siggy
Report Abuse
poppyseed101 is not online. poppyseed101
Joined: 25 Sep 2010
Total Posts: 78
21 Feb 2016 03:56 PM
I just.... what?

I can't script very well. You are correct in that sense.

If you wouldn't mind, just dumb it down to "first-time-scripter" level, because I'm not much above that.
Report Abuse
HumanXerxes is not online. HumanXerxes
Joined: 17 Apr 2011
Total Posts: 1351
21 Feb 2016 03:58 PM
Instead of "while true do" make it "while toggle do"?

Also, to make a variable local just put "local " before it.

local toggle=false
Report Abuse
crashproof is not online. crashproof
Joined: 18 May 2013
Total Posts: 250
21 Feb 2016 03:58 PM
alrigh make a interruption between x and y to force the statement of z. then do 4*y to result in while true do to of.


yes my siggy
Report Abuse
poppyseed101 is not online. poppyseed101
Joined: 25 Sep 2010
Total Posts: 78
21 Feb 2016 04:06 PM
STILL not sure what you mean. :(

Can you write a small example please?

I am absolute garbage at scripting.
Report Abuse
HumanXerxes is not online. HumanXerxes
Joined: 17 Apr 2011
Total Posts: 1351
21 Feb 2016 04:10 PM
crash is just trolling you btw:

local switch = script.Parent.Switch
local toggle = false

function lightswitch()
toggle = not toggle
if not toggle then
while toggle do
script.Parent.Front1.Material = Enum.Material.Neon
script.Parent.FMiddle1.Material = Enum.Material.Neon
script.Parent.MMiddle1.Material = Enum.Material.Neon
script.Parent.RMiddle1.Material = Enum.Material.Neon
script.Parent.Rear1.Material = Enum.Material.Neon
script.Parent.Front2.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.Rear2.Material = Enum.Material.SmoothPlastic
wait(0.5)
script.Parent.Front1.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.Rear1.Material = Enum.Material.SmoothPlastic
script.Parent.Front2.Material = Enum.Material.Neon
script.Parent.FMiddle2.Material = Enum.Material.Neon
script.Parent.MMiddle2.Material = Enum.Material.Neon
script.Parent.RMiddle2.Material = Enum.Material.Neon
script.Parent.Rear2.Material = Enum.Material.Neon
wait(0.5)
end
else
script.Parent.Front1.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.Rear1.Material = Enum.Material.SmoothPlastic
script.Parent.Front2.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.Rear2.Material = Enum.Material.SmoothPlastic
end
end

switch.ClickDetector.MouseClick:connect(lightswitch)

local variables actually won't make a difference here, but just make them local them anyway.
Report Abuse
poppyseed101 is not online. poppyseed101
Joined: 25 Sep 2010
Total Posts: 78
21 Feb 2016 04:11 PM
Ah, is he?

I was like "WHAT IS X, WHAT WOULD Z BE?"

Thanks for doing this though.
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
21 Feb 2016 04:13 PM
Fixed it for you:

local switch = script.Parent.Switch
local toggle = false

function lightswitch()
toggle = not toggle
if not toggle then
while toggle do
script.Parent.Front1.Material = Enum.Material.Neon
script.Parent.FMiddle1.Material = Enum.Material.Neon
script.Parent.MMiddle1.Material = Enum.Material.Neon
script.Parent.RMiddle1.Material = Enum.Material.Neon
script.Parent.Rear1.Material = Enum.Material.Neon
script.Parent.Front2.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.Rear2.Material = Enum.Material.SmoothPlastic
wait(0.5)
if not toggle then
break
end
script.Parent.Front1.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.Rear1.Material = Enum.Material.SmoothPlastic
script.Parent.Front2.Material = Enum.Material.Neon
script.Parent.FMiddle2.Material = Enum.Material.Neon
script.Parent.MMiddle2.Material = Enum.Material.Neon
script.Parent.RMiddle2.Material = Enum.Material.Neon
script.Parent.Rear2.Material = Enum.Material.Neon
wait(0.5)
end
else
script.Parent.Front1.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle1.Material = Enum.Material.SmoothPlastic
script.Parent.Rear1.Material = Enum.Material.SmoothPlastic
script.Parent.Front2.Material = Enum.Material.SmoothPlastic
script.Parent.FMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.MMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.RMiddle2.Material = Enum.Material.SmoothPlastic
script.Parent.Rear2.Material = Enum.Material.SmoothPlastic
end
end


Report Abuse
poppyseed101 is not online. poppyseed101
Joined: 25 Sep 2010
Total Posts: 78
21 Feb 2016 04:17 PM
Still not working. :(

Some of the parts are unions, and the only other part is the brick which the clickdetector is in.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image