Does anyone know how to make a randomizer?
Like, say for example, when a new server exists, a part can be either red, orange, or yellow.
Maybe have to where a script makes a NumberValue will change between 1 and 3. And when I figure that out I want to figure out how to make it like:
1 | if script.Parent.Value.Value = 1 then |
2 | script.Parent.Transparency = 1 |
3 |
4 | if script.Parent.Value.Value = 2 then |
5 | script.Parent.Transparency = 0.5 |
6 |
7 | if script.Parent.Value.Value = 3 then |
8 | script.Parent.Transparency = 0 |
9 | end |
Please help me.
Spoiler Alert,
On part of the Roblox game Isolator, in one of the rooms has a computer that says either Left or Right. I want to make something similar to that.
If
Math.random you can use different ways. One of those ways, is to generate a number through another number. But you might notice, if you use it more than once in the same game/server, it will keep generating the same number. So you can use math.randomseed to make the numbers generate more random each time. Now it should be different every time.
This would be a part touched event.
01 | math.randomseed(tick()) --Seeds the random number function by your local time. |
02 |
03 | debounce = false |
04 | local number = (math.random( 1 , 3 )) |
05 | script.Parent.Touched:Connect( function () |
06 | if debounce = = false then |
07 | if number = = 1 then |
08 | script.Parent.Transparency = 1 |
09 |
10 | elseif number = = 2 then |
11 | script.Parent.Transparency = 0.5 |
12 |
13 | elseif number = = 3 then |
14 | script.Parent.Transparency = 0 |
15 | end |
16 | debounce = true |
17 | wait ( 2 ) --Time you want before the next player can touch to change it |
18 | debounce = false |
19 | end |
20 | end ) |
This would be a part clicked event
01 | math.randomseed(tick()) --Seeds the random number function by your local time. |
02 |
03 | local number = (math.random( 1 , 3 )) |
04 | debounce = false |
05 | script.Parent.MouseClick:Connect( function () |
06 | if debounce = false then |
07 | if number = = 1 then |
08 | script.Parent.Transparency = 1 |
09 |
10 | elseif number = = 2 then |
11 | script.Parent.Transparency = 0.5 |
12 |
13 | elseif number = = 3 then |
14 | script.Parent.Transparency = 0 |
15 | end |
16 | debounce = true |
17 | wait( 2 ) --Time you want before the next player can click to change it |
18 | debounce = false |
19 | end |
20 | end ) |