gold = game.Players.LocalPlayer.leaderstats.Gold script.Parent.MouseButton1Click:connect(function() if gold.Value >= 100 then gold.Value = gold.Value - 100 local a = game.ReplicatedStorage.CharactersLevelOne:GetChildren() local b = a[math.random(1,#a)]:Clone() b.Parent = game.Workspace:WaitForChild("Monsters") b.Monster.Value = b.Monster.Value + 1 b.Parent = game.Workspace:WaitForChild("Monsters") script.Parent.Parent.MonsterCount.Value = script.Parent.Parent.MonsterCount.Value + 1 script.Parent.Parent.FirstSummon.Text = "Summoned monster" local x = game.Players.LocalPlayer.SaveMonsters:WaitForChild(b.Name) x.Value = x.Value + 1 wait(3) script.Parent.Parent.FirstSummon.Text = "1 ~ 3 100 gold" end if gold.Value < 99 then script.Parent.Parent.FirstSummon.Text = "Not enough money" wait(3) script.Parent.Parent.FirstSummon.Text = "1 ~ 3 powered 100 gold" end end)
So where is says a[math.random(1,#a)]:Clone() I want it to be a randomseed and I am not sure how so when I play the game, the item changes everytime you start the game..
As I've talked about and said about the math.randomseed function, although I can't confirm this definition, how it works is that it sets the primary seed for math.random; again, however, I can't confirm this.
math.randomseed can be very buggy and confusing from what I've seen, but I've also seen answers on how to fix this, but I can't find them, so I'll try and repost the answers here:
First, we need to set up randomseed:
math.randomseed()
BUT! Before we continue, we need to give the function an argument; a number of some sort.
Many recommend using tick
, as it always changes and becomes more random. Lets apply that:
math.randomseed(tick())
Now it'll work!! :D
Now, I'll be off...
ANSWER THE DANG QUESTION, YOU DIDN'T SAY THE REST!!
Fine. ;-;
After that, from what I've seen, you then call just the math.random function, without giving any argument(s), after you set up the seed. Here's how I've seen it:
math.randomseed(tick()) math.random()
That's how I remember others set it up, at least. e-e Now, when you fire it, it should produce a randomized number:
math.randomseed(tick()) math.random() print(math.random(1, 100)) -- Random Num Generated
Welp, sadly, that's all I know about it, and how others did it to prevent it from producing the same number over and over again. I'm sorry if this didn't answer your question. ;(
Functions and junk talked about To note: I've already talked about these previously, so I wont post any definitions again. ;C
The Randomseed Function
The Random Function
Although, I hope this helped you in any way! :D