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: Whats wrong here?

Previous Thread :: Next Thread 
Avocation is not online. 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
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
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
CardboardRocks is not online. CardboardRocks
Joined: 25 Dec 2011
Total Posts: 411
02 Mar 2015 04:23 PM
That or do until script.Parent.Parent.Parent.Overlay.BackgroundTransparency <= 0
Report Abuse
Avocation is not online. Avocation
Joined: 22 Mar 2011
Total Posts: 107
02 Mar 2015 04:23 PM
I figured it out, i changed == to <=
Report Abuse
Avocation is not online. Avocation
Joined: 22 Mar 2011
Total Posts: 107
02 Mar 2015 04:24 PM
that same time post doe.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
02 Mar 2015 04:24 PM
>still using a repeat loop

I cri


Oh well. At least it works, I guess.
Report Abuse
Avocation is not online. Avocation
Joined: 22 Mar 2011
Total Posts: 107
02 Mar 2015 04:25 PM
wait so whats the other loop type
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
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 is not online. 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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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
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