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

Expecting me to close table at random line?

Asked by 6 years ago

so im making a roblox minigame. im making a table but when i try to add 2 items, it tells me its expecting to close in line 13. (which has a random script)

minigames = {"BoulderRun" "Parkour"}
repeat
wait (1)
    CurrentMinigame = math.random(.2958239167056, #minigames)
    if CurrentMinigame == 1 then
        wait (15)
        workspace.Model.a.Transparency = 0
        workspace.Model.b.Transparency = 0
        workspace.Model.c.Transparency = 0
        workspace.Model.d.Transparency = 0
        workspace.Model.e.Transparency = 0
        workspace.Model.f.Transparency = 0
        workspace.Model.g.Transparency = 0 --asking me to put it here.
        workspace.Model.h.Transparency = 0
        workspace.Model.i.Transparency = 0
        workspace.Model.j.Transparency = 0
        workspace.Model.Model1.Boulder1.Transparency = 0
        workspace.Model.Model2.Boulder2.Transparency = 0
        workspace.Model.Model3.Boulder3.Transparency = 0
        wait (20)
        workspace.Model.a.Transparency = 1
        workspace.Model.b.Transparency = 1
        workspace.Model.c.Transparency = 1
        workspace.Model.d.Transparency = 1
        workspace.Model.e.Transparency = 1
        workspace.Model.f.Transparency = 1
        workspace.Model.g.Transparency = 1
        workspace.Model.h.Transparency = 1
        workspace.Model.i.Transparency = 1
        workspace.Model.j.Transparency = 1
    elseif CurrentMinigame == 2 then
        wait (15)
        workspace.Lobby.Orb.Transparency = .5

    end
until 5 == 2
0
You have to put a comma between each item in a table theCJarmy7 1293 — 6y

1 answer

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

TheCJ is correct in that you must use either a comma or semi-colon as a separator in tables (and most people use the comma).

However, I'd like to point a few other things out about this.

Firstly, math.random() with no arguments generates a real number from [0, 1] such as 0.28382238. math.random(m) with one argument generates an integer from [0, m], such as 2 or 5 in math.random(5). Finally, math.random(m, n) with two arguments generates an integer from [m, n], such as 592, 1, or 867 in math.random(1, 10000).

So you're actually calling the function improperly and it will give you an error.

I'd also encourage you to loop into loops for setting the transparency of models, because you seem to be repeating yourself a lot there.

Worth noting that 5 == 2 will never be truthy (I assume you know this), but if you did intentionally write that, you can just use a while true do loop with no need for a repeat until if you'd like.

0
that math random .2958239167056 was just a little test thing. i was going to put that back into 1. but thanks for your help! roblozinko 15 — 6y
0
Thanks, if I helped you, please feel free to accept my answer and/or vote on it! Avigant 2374 — 6y
Ad

Answer this question