Hi there, I’m trying to experiment with math.random(number, number) so I attempted to make a simple automatic map chooser. However, I get this error 13:59:31.115 - ServerScriptService.Script:6: attempt to call a table value
I don’t know how to solve the issue, but here’s the script.
game.ReplicatedStorage.NewMapGeneration.OnServerEvent:Connect(function()
local H = {}
H[1] = game.Lighting.Puzzle1
H[2] = game.Lighting.Puzzle2
H[3] = game.Lighting.Puzzle3
:Clone(H(math.random(1,3))).Parent == workspace
end)
I’m assuming “:Clone(H(math.random(1,3))).Parent == workspace” is all there is to that line
:Clone comes after identifying the object, it’s a function of that object so it would be obj:Clone().Parent = workspace. == is for comparing, for example in if statements, while loops, etc. = is for assigning
To get table elements you use [] not (). So it would be H[math.random(1,3)]
All put together it would become in this order obj:Function so