So, I'm trying to do a script that involves not only races, but also another factor (Will of D), but that part is somewhat irrelevant. Each time I run the game, an error appears in Roblox Studio's output:
ServerScriptService.RaceScript:20: attempt to index number with number
Here's the script from line 15-33, and apparently the issue is in line 20. Anyone know the problem and solution to this?
17.local raceweight = 0
19.for racechancesdata in pairs(racechances) do
20.raceweight = raceweight + racechancesdata[2]
21.end
23.--Randomizing
24.function randomizerace()
25.local chance = math.random(1,raceweight)
26.local counter = 0
27.for racechancesdata in pairs(racechances) do
28.counter = counter + racechancesdata[2]
29.if chance <= counter then
30.return racechancesdata[1]
31.end
32.end
33.end