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 4 years ago
Edited 4 years ago
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.

1 answer

Log in to vote
1
Answered by 4 years ago
--// Settings
local Prefix = ":"

--// PlayerAdded
game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if string.sub(msg:lower(), 1, 5) == Prefix.."play" then
            pcall(function()
                local MusicID = string.sub(msg, 7)
                if MusicID then
                    game.Workspace.Sound.SoundId = "rbxassetid://"..MusicID
                    game.Workspace.Sound:Play()
                end
            end)
        end
    end)
end)
0
Thanks, works perfectly man. iinaoriku 52 — 4y
Ad

Answer this question