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

Will someone tell me why line 31 keeps erroring out and whats causing it?

Asked by
Prioxis 673 Moderation Voter
10 years ago

I'm making a minigames game but the main script it errors out every time on line 31.... will someone please tell me why? and fix it?

01minigames = game.Lighting.minigames:GetChildren()
02 
03h = Instance.new("Hint", Workspace)
04 
05function removePlate()
06    plates = game.Workspace.DissapearingPlates.Plates:GetChildren()
07    ranNum1 = math.random(1, #plates)
08    ranNum2 = 1
09    while ranNum1 == ranNum2 do
10        ranNum2 = math.random(1, #plates)
11        wait()
12    end
13    plateChosen = plates(ranNum1)
14    plateChosen2 = plates(ranNum2)
15    for i = 0, 1, 0.05 do
View all 81 lines...
0
Any output at all? If there is some output, it would be quite helpful if you added it! OniiCh_n 410 — 10y
0
yeah sorry I forgot 13:59:11.510 - Workspace.MainScript:34: attempt to call global 'minigames' (a table value) 13:59:11.511 - Stack Begin 13:59:11.511 - Script 'Workspace.MainScript', Line 34 13:59:11.512 - Stack End? Prioxis 673 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

On line 34, use [brackets], not (parenthesis). Although I think you also need to use math.floor / math.ceil to make sure the number chosen is not a decimal, although I'm not sure.

1local ranGame = math.floor(math.random(1,#minigames)) --I think this is needed, correct me if I am wrong
2local gameChosen = minigames[ranGame] --Using brackets
3--Also I would put the word local before the variables so I don't end up declaring them globally. This isn't needed though.
0
alright yay thank you Prioxis 673 — 10y
0
math.random only returns whole numbers, not decimals. SlickPwner 534 — 10y
0
Just tested math.random(), and it returns a decimal. Octillerysnacker 115 — 10y
Ad

Answer this question