Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to Ensure that the 2nd String of this value doesn't get the First one?

Asked by 4 years ago
Edited 4 years ago

ok so I need to make it that the 2nd string of the value doesn't get the same as the first one

local Rand = Random.new(tick())
local Elements = {"Earth", "Fire", "Lightning", "Water"}

Element.Value = Elements[Rand:NextInteger(1, #Elements)] .. " / " .. Elements[Rand:NextInteger(1, #Elements)]

i need to make it not to pick the same EX: Fire / Fire

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
local Elements = {"Earth", "Fire", "Lightning", "Water"}

local Random = Random.new(tick())

local FirstElement = Elements[Random:NextInteger(1,#Elements)]
local SecondElement;
repeat wait()
    SecondElement = Elements[Random:NextInteger(1,#Elements)]
until SecondElement ~= FirstElement

Elements.Value = FirstElement.." / "..SecondElement
Ad

Answer this question