Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What does this error mean? [UNSOLVED]

I have no idea what this error means.

21:27:06.767 - Players.Player1.PlayerGui.LocalScript:5: bad argument #2 to 'random' (interval is empty) 21:27:06.771 - Script 'Players.Player1.PlayerGui.LocalScript', Line 5 21:27:06.774 - Stack End Script:

faces = {face1 = "http://www.roblox.com/asset/?id=162384466",face2 = "http://www.roblox.com/asset/?id=162387197",face3 = "http://www.roblox.com/asset/?id=162387541"}
h = script.Parent.Parent.Character.Head
player = game.Players.LocalPlayer
hft = h.face.Texture
rm = math.random(1,#faces)
hft = rm

I have all the asset ids right cause i -1 them all so I don't know whats going on now. Please help! Thanks!

1 answer

faces is a dictionary instead of an array, so it returns nil. So the math.random sees (1, nil), then It will tell you interval is empty, because a required argument is not found (nil = nothing) Solution: turn it into an array and I will get you a bonus, get it working from what I see

faces = {"http://www.roblox.com/asset/?id=162384466", "http://www.roblox.com/asset/?id=162387197","http://www.roblox.com/asset/?id=162387541"}
rm = math.random(1,#faces)
script.Parent.Parent.Character.Head.face.Texture = faces[rm]

I've tested it By the way, repeatedly asking will get you anywhere.

1 comment

0

That is supposed to work, but don't you think it would be more efficient if you did asset = faces[rm]?

This discussion is preserved as it was. New answers, comments, and votes are closed.