1 | game.Workspace.SoundPart.Sound:Play() |
I made a very simple line of code, but I'm having trouble changing the sound ID using player chats, EX: play/(song id)
Could anyone help me with this? I know how to use player chat to change properites of bricks but i dont know how to change the song ID with it. Thanks.
01 | --// Settings |
02 | local Prefix = ":" |
03 |
04 | --// PlayerAdded |
05 | game.Players.PlayerAdded:Connect( function (plr) |
06 | plr.Chatted:Connect( function (msg) |
07 | if string.sub(msg:lower(), 1 , 5 ) = = Prefix.. "play" then |
08 | pcall ( function () |
09 | local MusicID = string.sub(msg, 7 ) |
10 | if MusicID then |
11 | game.Workspace.Sound.SoundId = "rbxassetid://" ..MusicID |
12 | game.Workspace.Sound:Play() |
13 | end |
14 | end ) |
15 | end |
16 | end ) |
17 | end ) |