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

What does this error mean? [UNSOLVED]

Asked by 10 years ago

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 EndScript:

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

Log in to vote
0
Answered by 10 years ago

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.

0
That is supposed to work, but don't you think it would be more efficient if you did asset = faces[rm]? M39a9am3R 3210 — 10y
Ad

Answer this question