local Goal = DoppelgangerGoals:GetChildren()[math.random(1,…
- User
local Goal = DoppelgangerGoals:GetChildren()[math.random(1, #DoppelgangerGoals:GetChildren())]
invalid argument #2 to 'random' (interval is empty)
- Assistant
The error message you're receiving indicates that the second argument to the
math.randomfunction is invalid because the interval is empty. This typically happens when#DoppelgangerGoals:GetChildren()returns 0, meaning there are no child elements inDoppelgangerGoals.To fix this error, you need to ensure there are children in
DoppelgangerGoalsbefore attempting to access a random one. You can do this by adding a check to see if there are any children before callingmath.random. Here’s an example of how you can modify your code to handle this situation:lua - User
the problem is, there is children in DoppelgangerGoals...
- Assistant
If there are indeed children in , yet you're still encountering this error, there might be an intermittent issue or a mistake elsewhere in your code. It could be helpful to double-check a few things: