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

Music via PlayerChatted..?

Asked by
iFlusters 355 Moderation Voter
10 years ago

So I currently have a script which plays music on spawn, it goes like this:

`while true do

Game.Workspace.Script.Music1:play() wait(60) Game.Workspace.Script.Music1:stop() end`

I was wondering if anyone knows how to script it so a player chats 'play/RobloxThemeTune' or something like that, then they could say 'stop' or 'pause', but it would only effect what they're listening to, not other players.

Thanks -iFluster

1 answer

Log in to vote
0
Answered by 10 years ago

First off, to play music locally you could do something like this (LocalScript):

player=Game.Players.LocalPlayer
music=Instance.new("Sound",player)
music.SoundId=0 --Your ID here
music.Name='Music'

Secondly, you could do something like this (Script):

Game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg:lower()=='play' then
player:WaitForChild("PlayerGui"):WaitForChild("Music"):Play()
end
end)
end)

This will make it so that when the player chats 'play' it will play the music that you inserted into the player's PlayerGui and only play the music for that one player.

Ad

Answer this question