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

Why isn't a random model spawning when I have a script?

Asked by 5 years ago

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)
0
Royaltoe: I didn't forget you User#30241 0 — 5y
1
on line 7 make it .... local randomModel = models[math.random(1,#models)] ForeverBrown 356 — 5y
0
Wdym foreverbrown do I backspace the 3 User#30241 0 — 5y
0
you're using math.random(min, max) but you have a random "3" that is not needed in the parameter SerpentineKing 3885 — 5y

Answer this question