I have a script that is not working even though I am trying to put it in right. Its a script that is suppose to spawn a random model from a folder in "Lighting". But it doesn't work no matter what I do. Please help

Here is the script:

clicker = script.Parent

clicker.ClickDetector.MouseClick:Connect(function(player)
 local models = game.Lighting.Models:GetChildren()

 --get a random model by picking a random number in the range of 1 through the number of models inside the models group/folder: 
 local randomModel = models[math.random(1,3 #models)]

--clone model and put it into workspace: 
	local modelClone = randomModel:Clone()
	modelClone.Parent = game.Workspace
end)

4 comments

0

Royaltoe: I didn't forget you

1

on line 7 make it .... local randomModel = models[math.random(1,#models)]

0

Wdym foreverbrown do I backspace the 3

0

you're using math.random(min, max) but you have a random "3" that is not needed in the parameter