Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
--// 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)

1 comment

0

Thanks, works perfectly man.

This discussion is preserved as it was. New answers, comments, and votes are closed.