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: Math.random error

Previous Thread :: Next Thread 
Interjecti0n is not online. Interjecti0n
Joined: 08 Dec 2013
Total Posts: 257
14 Aug 2016 07:22 AM
I got my script:

function onTouched(hit)
local luck = math.random(1,5)

if luck == 1 then
hit.Parent.Humanoid.Walkspeed = 50
script.Parent:Destroy()
wait(2)
hit.Parent.Humanoid.Walkspeed = 16
elseif luck == 2 then
hit.Parent.Humanoid.Walkspeed = 5
wait(5)
hit.Parent.Humanoid.Walkspeed = 16
elseif luck == 3 then
hit.Parent.Humanoid.PlatformStand = true
wait(3)
hit.Parent.Humanoid.PlatformStand = false
elseif luck == 4 then
hit.Parent.Humanoid.Walkspeed = 100
wait(3)
hit.Parent.Humanoid.Walkspeed = 5
wait(2)
hit.Parent.Humanoid.Walkspeed = 16
elseif luck == 5 then
local a = Instance.new("Smoke")
a.Parent = hit.Parent.Humanoid
wait(5)
a:Destroy()
end

script.Parent:Destroy()

end

script.Parent.Touched:connect(onTouched)


I got this is in a brick, but, I always get the same luck.
Is there anyway to get a random luck?


Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
14 Aug 2016 07:25 AM
put this at the very top:
math.randomseed(tick())


Report Abuse
Interjecti0n is not online. Interjecti0n
Joined: 08 Dec 2013
Total Posts: 257
14 Aug 2016 07:28 AM
math.randomseed(tick())

function onTouched(hit)

local luck = math.random(1,5)

if luck == 1 then
hit.Parent.Humanoid.Walkspeed = 50
script.Parent:Destroy()
wait(2)
hit.Parent.Humanoid.Walkspeed = 16
elseif luck == 2 then
hit.Parent.Humanoid.Walkspeed = 5
wait(5)
hit.Parent.Humanoid.Walkspeed = 16
elseif luck == 3 then
hit.Parent.Humanoid.PlatformStand = true
wait(3)
hit.Parent.Humanoid.PlatformStand = false
elseif luck == 4 then
hit.Parent.Humanoid.Walkspeed = 100
wait(3)
hit.Parent.Humanoid.Walkspeed = 5
wait(2)
hit.Parent.Humanoid.Walkspeed = 16
elseif luck == 5 then
local a = Instance.new("Smoke")
a.Parent = hit.Parent.Humanoid
wait(5)
a:Destroy()
end

script.Parent:Destroy()

end

script.Parent.Touched:connect(onTouched)

I get the same thing every time..


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
14 Aug 2016 08:25 AM
math.randomseed(math.random(tick()))
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
14 Aug 2016 08:39 AM
No that's dumb, math.randomseed(tick()) is just fine for seeding it. What you suggested is worse.

@op
have you tried it in online mode and it does the same thing?


Report Abuse
Interjecti0n is not online. Interjecti0n
Joined: 08 Dec 2013
Total Posts: 257
14 Aug 2016 08:40 AM
Help me then lol ^^ :)


Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
14 Aug 2016 08:43 AM
You should put a debounce in like

local db = false
function touch(whatever)
if db==false then
db = true
--stuff
wait(1)
db = false
end
end


Report Abuse
Interjecti0n is not online. Interjecti0n
Joined: 08 Dec 2013
Total Posts: 257
14 Aug 2016 08:44 AM
I don't know how to use debounce..


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
14 Aug 2016 08:52 AM
"No that's dumb, math.randomseed(tick()) is just fine for seeding it. What you suggested is worse."

when I used math.randomseed(tick()), i ran it like 20 times and got 1 every time
so you're wrong
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
14 Aug 2016 08:59 AM
youtube.com/watch?v=VxeEr3wUonQ


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