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

Using player chatted to change song ID (SIMPLE)???

Asked by 5 years ago
Edited 5 years ago
1game.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.

1 answer

Log in to vote
1
Answered by 5 years ago
01--// Settings
02local Prefix = ":"
03 
04--// PlayerAdded
05game.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)
17end)
0
Thanks, works perfectly man. iinaoriku 52 — 5y
Ad

Answer this question