Attempt to call table value? ( 13:59:31.115 - ServerScriptService.Script:6: attempt to call a table value )

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)
1 Like

The variable H is a table value.
Did you mean:

H[math.random(1, 3)]
2 Likes

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

H[math.random(1,3)]:Clone().Parent = workspace
1 Like

Also to save lines, instead of

local H = {}
H[1] = game.Lighting.Puzzle1
H[2] = game.Lighting.Puzzle2
H[3] = game.Lighting.Puzzle3

you could do

local H = {game.Lighting.Puzzle1, game.Lighting.Puzzle2, game.Lighting.Puzzle3}
1 Like

I think so, I’m still new to this and I’m going off of tutorials/ the developer.roblox.com website.

Ohh, I see.

i need to reach 30 c