Okay, I tried to find information for random, but to no avail.
I hope there are people who will explain my mistake.
Try watching a youtube video about it that should work
or it could be a roblox studio bug
I looked, but couldn’t find a suitable one.
watch this youtube video
Advanced Roblox Scripting Tutorial #18 - Math Functions (Beginner to Pro 2019)
Also watch a lot of videos they help a lot people out
indcluding myself!
what does CreateEntity_2 do and try printing math.random(1,#Entity) in CreateEntity
I think his trying to create a entity with a math
i am not sure im new to scripting lmao
local stuff = {"this", "that", "more", "or", "less"}
print(stuff[math.random(1,#stuff)])
I think you’re calling the number of the random pick and not what that number is.
okay dude am I too stupid in this world or are you just a genius lol
math.random(x,y)
will give you a random number from x to y. If the first argument you’re trying to provide to CreateEntity_2 should be a number than it would work. Otherwise you’ll need to wrap it in Entity[math.random(1,#Entity)]
if you’re trying to provide the “Runner” or “Leader Zombie” strings instead.
Also I would highly suggest using the new Random
library instead of math.random
. You can find details about it here.
One last thing: If your second number in math.random is less than the first number (usually as a result of an empty table, but wont happen in your case), then it will throw an error. This doesn’t happen for Random.new():NextInteger()
.
Syntax errors that still work in a way are some of the hardest things to debug.
I’ll bet you never get that wrong again …