✓ Accepted answer
Every math.random without a seed uses the same seed, and this creates the same result. To fix this, you can use Random.new().
local rand = Random.new(tick())
local Power= {"Earth", "Fire", "Lightning", "Water"}
Player.Power.Element1.Value = Power[rand:NextInteger(1, #Power)]
Player.Power.Element2.Value = Power[rand:NextInteger(1, #Power)]
EDIT:
local rand = Random.new(tick())
local Power= {"Earth", "Fire", "Lightning", "Water"}
Player.Power.Element1.Value = Power[rand:NextInteger(1, #Power)]
repeat
Player.Power.Element2.Value = Power[rand:NextInteger(1, #Power)]
until Player.Power.Element2.Value ~= Player.Power.Element1.Value
If there are any errors, please comment.
6 comments
is there a chance that it'll pick the same string?
There is a small chance, just by random chance. You can implement safeguards against this easily however.
Editted to show this process.
Aight Thx.
Or math.randomseed
It's generally better practice to use Random.new().