✓ Accepted answer
For some reason the past two answers are "not working" according to OP so I am posting. (Despite Feahrens answer being correct :l)
Question
Attempt to index nil with 'random'?
Solution
The error is on line 4.
game.Workspace.Name = scriptnames.math.random(0,#table)
The issue is that you're attempting to index table scriptnames with key math and then index that with random. The issue is that there is no index math inside table scriptnames.
I assume this code is meant to pick a random value from scriptnames. If you want to pick a random value from an array you will want to first generate a random number such that the lowest value is the 1st index of the array the maximum value is the amount of things in said array. This can be achieved by doing math.random(1, #array).
Now using this random number we can index our array with the number to get a random index. array[math.random(1, #array)]`
Using this knowledge you should be able to come up with the code below, which solves your problem:
game.Workspace.Name = scriptnames[math.random(1, #scriptnames)]
This will index scriptnames with a random number between 1 and the amount of indices in scriptnames, then assign the Name property of the Workspace service to that value.
2 comments
try reading this : https://scriptinghelpers.org/questions/67819/is-there-a-way-i-can-change-the-name-of-workspace-every-5-seconds
Next time describe your problem explicitly. And also make sure to show the error.