T_ry
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 230 |
|
|
| 13 Sep 2016 06:38 AM |
So I'm working on making a case opening type of thing, so far it works fine and spins randomly. But when it gets to a certain point, it doesn't re-loop around. This is what my script looks like:
wait(2)
local i = 0
while i < math.random(50,100) do script.Parent.Position = script.Parent.Position + UDim2.new(0.01,0,0,0) i = i + 1 wait(0.01) if script.Parent.Position == UDim2.new(1.7,0,0,0) then print('good succ') end end
|
|
|
| Report Abuse |
|
|
|
| 13 Sep 2016 06:41 AM |
| When it gets to 98 there are almost no chances that it'll work |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2016 06:42 AM |
The simplest fix would be to reset the i to 0 when it gets to a high value if i>80 then i=0 end But the script is kinda weird by itself. |
|
|
| Report Abuse |
|
|
T_ry
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 230 |
|
|
| 13 Sep 2016 06:43 AM |
@noone what do you mean by that?
|
|
|
| Report Abuse |
|
|
mooing
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 79 |
|
|
| 13 Sep 2016 07:23 AM |
#o#I#m#w#r#i#g#o# #a#i#g#a#c#s# #p#n#n# #y#e#o# #h#n#,#s# #a# #t#w#r#s#f#n# #n# #p#n# #a#d#m#y# #u# #h#n#i# #e#s#t# # #e#t#i# #o#n#,#i# #o#s#'# #e#l#o# #r#u#d# #h#s#i# #h#t#m# #c#i#t#l#o#s#l#k#:
w#i#(#)
#o#a# # # #
w#i#e#i#<#m#t#.#a#d#m#5#,#0#)#d# #c#i#t#P#r#n#.#o#i#i#n#=#s#r#p#.#a#e#t#P#s#t#o# # #D#m#.#e#(#.#1#0#0#0# # # # # # #a#t#0#0#) i# #c#i#t#P#r#n#.#o#i#i#n#=# #D#m#.#e#(#.#,#,#,#)#t#e#
p#i#t#'#o#d#s#c#'# #n#
#n#
|
|
|
| Report Abuse |
|
|
|
| 13 Sep 2016 12:14 PM |
| It doesn't reloop because i is always being increases by 1, and since the math.random is always between 50 and 100, there is no logical way it'll work when i gets to 100. And even then you have only 1 in 100 chances of getting to 100. |
|
|
| Report Abuse |
|
|
T_ry
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 230 |
|
|
| 13 Sep 2016 12:14 PM |
@noone it doesn't matter, thanks for your input/help but I've found a more efficient way of performing this.
|
|
|
| Report Abuse |
|
|
Haukly
|
  |
| Joined: 15 Apr 2012 |
| Total Posts: 1728 |
|
|
| 13 Sep 2016 12:54 PM |
@T_ try this:
local i = 0 wait(1.5) while i < math.random(50,150) do script.Parent.Position = script.Parent.Position + UDim2.new(0.02,0,0,0) wait(0.01) i = i + 1 wait(0.01) if script.Parent.Position == UDim2.new(1.7,0,0,0) then print('Ihopeitworked') end end
If this doesnt work I`ll try to make the full script new for you.
|
|
|
| Report Abuse |
|
|
| |
|
Haukly
|
  |
| Joined: 15 Apr 2012 |
| Total Posts: 1728 |
|
|
| 13 Sep 2016 12:57 PM |
Oh, sorry. But I think mine would have maybe worked. But not in FE.
|
|
|
| Report Abuse |
|
|