Currently i am wanting to code a music script that auto plays a playlist but
every time i try code one it goes wrong.
I have been watching videos on this but i cant find one where i can override the SoundID so
when i type the command /play 1234 - The SoundID it plays that specific Sound.
1 Like
I tried doing a script for you. It works just like you said. You’re free to change and modify the prefix and who can use it. Basically, What the script does, Is to check whether the Player that has joined has access to use the command - If so, It’s gonna listen to whenever the Player chats, And then do the magic!
It’ll split the arguments to whitespaces (every whitespace is equivalent to a parameter) the first argument should be the prefix + the play command (something like /play) and the second one should be the music ID. (Beware that most of sounds may not work as Roblox recently changed the Audio Security and it’s Terms) Try using the Script below and let me know if it works! 
-- Services
local WorkspaceService = game:GetService("Workspace")
local Players = game:GetService("Players")
-- Variables
local CommandPrefix = "/" -- Prefix to call the Command; e.g, "!play"
local AllowedUserIDs = {1701428729} -- Put your UserId(s) inside here
local ActiveSound = nil
-- Main
Players.PlayerAdded:Connect(function(Player)
if table.find(AllowedUserIDs, Player.UserId) then
Player.Chatted:Connect(function(Message)
-- User is Allowed to use Music command:
-- Transform the message into lowercase;
-- Split the message into different arguments.
local Message = string.lower(Message)
local SplittedArguments = string.split(Message, " ")
-- Checking if we have enough arguments;
-- Did we call the command?
if SplittedArguments and #SplittedArguments > 1 then
if SplittedArguments[1] == CommandPrefix.."play" then
-- If the sound is playing, Destroy it and create a new one.
-- SplittedArguments[2] is equals to the ID.
if ActiveSound then
ActiveSound:Destroy()
ActiveSound = nil
end
-- Create a new Sound and Play it.
ActiveSound = Instance.new("Sound")
ActiveSound.Name = "ActiveSound"
ActiveSound.Volume = 0.25
ActiveSound.SoundId = tostring("rbxassetid://"..SplittedArguments[2])
ActiveSound.Parent = WorkspaceService
-- The audio didn't loaded; Await until it loads.
-- Then play the Sound.
if not ActiveSound.Loaded then
warn("[SoundScript]: Sound didn't Load - Awaiting until it Loads!")
ActiveSound.Loaded:Wait()
end
ActiveSound:Play()
end
end
end)
end
end)
2 Likes
Thank you. I will try this next time I’m in studio