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 » Scripting Helpers
Home Search
 

Re: Anti-Number_Repeat, Helps

Previous Thread :: Next Thread 
4444vince2 is not online. 4444vince2
Joined: 08 Nov 2008
Total Posts: 4880
28 Jul 2014 04:21 AM
--Is there a better way to do this cause this like to error and break sometimes.


--This function makes it so you won't use the same number twice in a row.
ln = nil

function Num()
ln = math.random(1,4)
if ln == script.Last_Num.Value then
wait() print'Re-Try' Num() return
end
script.Last_Num.Value = gt
end

Num()
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
28 Jul 2014 04:29 AM
local last_used = 0

function use()
local new_num = 0
repeat new_num = math.random(1,4) until last_used ~= new_num
-- generates a new number until it isn't the last one.
end

The return keyword breaks the function. It returns the value and stops all execution afterwards.

If you were to do it via player input...

local last_used = script.Last_num

function use(number)
if(last_used.Value == number)then
print("Retry")
return
end
last_used = number
end
end

use(3)
Report Abuse
4444vince2 is not online. 4444vince2
Joined: 08 Nov 2008
Total Posts: 4880
28 Jul 2014 04:44 AM
Thanks
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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