Avocation
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 107 |
|
|
| 02 Mar 2015 04:20 PM |
Why isn't the loop stopping??
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function() -- if script.Parent.Square.BuyGamepass.Visible == false then script.Parent.Parent.TPSound:Play() repeat wait(.035) script.Parent.Parent.Parent.Overlay.BackgroundTransparency = script.Parent.Parent.Parent.Overlay.BackgroundTransparency - 0.01 until script.Parent.Parent.Parent.Overlay.BackgroundTransparency == 0 wait() script.Parent.Parent.TPSound:Stop() game:GetService("TeleportService"):Teleport(222381228, player) -- end end) |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2015 04:22 PM |
Floating point inaccuracies. BackgroundTransparency gets to a value that is incredibly close to 0, but not actually zero.
You should use a for loop for this, not a repeat loop. |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2015 04:23 PM |
| That or do until script.Parent.Parent.Parent.Overlay.BackgroundTransparency <= 0 |
|
|
| Report Abuse |
|
|
Avocation
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 107 |
|
|
| 02 Mar 2015 04:23 PM |
| I figured it out, i changed == to <= |
|
|
| Report Abuse |
|
|
Avocation
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 107 |
|
| |
|
|
| 02 Mar 2015 04:24 PM |
>still using a repeat loop
I cri
Oh well. At least it works, I guess. |
|
|
| Report Abuse |
|
|
Avocation
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 107 |
|
|
| 02 Mar 2015 04:25 PM |
| wait so whats the other loop type |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2015 04:27 PM |
for loops
They can repeat through a table or repeat a certain number of times. Only use integer steps because floating points again.
for i = 1, 5 do
Will loop the code afterwards 5 times, with the i variable ranging from 1 to 5.
for i = 5, 1, -1 do
Does the same thing, but counts down. You have to specify, in this case, you want to decrease i by 1 every loop. |
|
|
| Report Abuse |
|
|
Avocation
|
  |
| Joined: 22 Mar 2011 |
| Total Posts: 107 |
|
|
| 02 Mar 2015 09:50 PM |
| so how would you make it count up? for i = 1, 5 + 1 do? |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2015 09:54 PM |
for i = 1,2 do
end i = 1 i = 2
for i = 1,2,1 do
end i = 1 i = 2
for i = 1,5,2 do
end i = 1 i = 3 i = 5 |
|
|
| Report Abuse |
|
|