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

I cannot figure out why this "list" has a syntax error?

Asked by 2 years ago

Hello everyone! I am currently working on a script for my game that when a certain button is clicked. It will play a random song for the shop menu. I already know how to use math.random. But, I cannot figure out for the life of me, why this list isn't working. here is the errors I am getting. (Note: I don't receive any errors in the console, only script analysis.)

Errors with code: https://imgur.com/a/cRx7rfS

shopMusicList = {
    game.Workspace.Soundtrack.ShopSoundtrack.shopMusic_1
    game.Workspace.Soundtrack.ShopSoundtrack.shopMusic_2
    game.Workspace.Soundtrack.ShopSoundtrack.shopMusic_3
}

Explorer location: https://imgur.com/a/HheZAeT

If anyone knows the reason and can help me out with this, that would be great. :)

0
You are missing commas between your table elements. Beyond that, with the code you have provided, I don't see anything out of place. appxritixn 2235 — 2y

1 answer

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

Problem:

You didn't separate the items with a comma in the table. Essentially the code will think that the items in the table aren't needed since the table isn't enclosed at line 15 and hence will cause this error.

Solution

Remember to separate the items you want in the table with either a comma or a semi-colon and that will fix the error!

Fixed Script:

shopMusicList = {
    game.Workspace.Soundtrack.ShopSoundtrack.shopMusic_1,
    game.Workspace.Soundtrack.ShopSoundtrack.shopMusic_2,
    game.Workspace.Soundtrack.ShopSoundtrack.shopMusic_3,
}

Ad

Answer this question