Why wont this work? BTW NewCMD And function(msg) are flawless.
NewCMD("Music", "music", "Play's Music",funtion(msg) if msg == "list" then Tablet("Skrillex, Cinema (1)", Colors.Lime) Tablet("Cant Touch This (2)", Colors.Lime) Tablet("Only Girl In The World (3)", Colors.Lime) Tablet("Harlem Shake (4)", Colors.Lime) Tablet("Roar (5)", Colors.Lime) Tablet("Payphone (6)", Colors.Lime) Tablet("Counting Stars (7)", Colors.Lime) Tablet("Bangarang (8)", Colors.Lime) Tablet("They See Me Trollin' (9)", Colors.Lime) Tablet("Life Of A Noob (10)", Colors.Lime) elseif msg == "1" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 130777688 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 130777688 end elseif msg == "2" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131122314 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131122314 end elseif msg == "3" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 134580833 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 134580833 end elseif msg == "4" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131154740 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131154740 end elseif msg == "5" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131065183 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131065183 end elseif msg == "6" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131396974 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131396974 end elseif msg == "7" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 138130725 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 138130725 end elseif msg == "8" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131810766 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 131810766 end elseif msg == "9" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 138143795 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 138143795 end elseif msg == "10" then if not workspace:FindFirstChild("Sound")then Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 196917825 else game.Workspace.Sound:Remove() Sound = Instance.new("Sound") Sound.Parent = game.Workspace Sound.SoundId = 196917825 end end end)
The error:
Error on line 5628. ")" expected (to close "(" at line 5627) near "if"
And yes, im not stupid, i tried adding a "(" at line 5628 and i tried to add an extra ")" to close it
Indexing a game object which does not exist will error.
Instead of checking if game.Workspace.Sound == nil then
, which will error if the sound does not exist, use FindFirstChild
:
if not workspace:FindFirstChild("Sound")then
Also function
is spelled wrong on the first line.
To fix it look for a ( that doesnt have a ) to close it. It doesnt tell you the line it needs to go on just the line that it starts at.