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

How would I make it so when a certain person says the word skip, it skips the song?

Asked by 6 years ago
Edited 6 years ago

How would I make it so that when like a certain person ("namehere") says "skip song" it skips to the next song? here is my songboard script

print 'Loading Playlist'
song1 = "http://www.roblox.com/asset/?id=299075527" --ellie goulding on my minf
song2 = "http://www.roblox.com/asset/?id=292433682" -- death of a bachelor p!atd
song3 = "http://www.roblox.com/asset/?id=589851184" --- halleujah
song4 = "http://www.roblox.com/asset/?id=787636293" --- zed stay
song5 = "http://www.roblox.com/asset/?id=666248225" -- something just like this
song6 = "http://www.roblox.com/asset/?id=156850138" --nico and vinz
song7 = "http://www.roblox.com/asset/?id=561274893" --starboy
song8 = "http://www.roblox.com/asset/?id=188712851"--shut up and dance
song9 = "http://www.roblox.com/asset/?id=685388224"--magine dragons believer
song10 = "http://www.roblox.com/asset/?id=882915526"--mad hatter melanie martinez
song11 = "http://www.roblox.com/asset/?id=501405545"--lane boy
song12 = "http://www.roblox.com/asset/?id=610923182"--paris
song13 = "http://www.roblox.com/asset/?id=444240273"--mo final song
song14 = "http://www.roblox.com/asset/?id=181547615"--Centuries
song15 = "http://www.roblox.com/asset/?id=152357361"
song16 = "http://www.roblox.com/asset/?id=145579822"
song17 = "http://www.roblox.com/asset/?id=148492408"
song18 = "http://www.roblox.com/asset/?id=142720946"
song19 = "http://www.roblox.com/asset/?id=142372565"
song20 = "http://www.roblox.com/asset/?id=152779074"
song21 = "http://www.roblox.com/asset/?id=145915908"
song22 = "http://www.roblox.com/asset/?id=138855854"
song23 = "http://www.roblox.com/asset/?id=259802648"
song24 = "http://www.roblox.com/asset/?id=641912399"




print 'Creating a Source of Audio'
local music = Instance.new("Sound") 
music.Archivable = true 
print 'Inspecting the Configurable Variables'



music.Parent = script.Parent 

music.Pitch = 1 
music.Volume = 3 
music.Looped = false
music.Name = "Player"
print 'Loading RMP 1.0'
while (true) do
    print 'Playing Sound 1'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Ellie Goulding - On My Mind")

music.SoundId = song1 

music:play()
wait(150) 
    --2--
    print 'Playing Sound 2'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Panic! at the Disco - Death of a Bachelor")

music.SoundId = song2
music:play() 
wait(150)
    --3--
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Pentatonix - Hallelujah")
    print 'Playing Sound 3'
music.SoundId = song3
music:play() 
wait(200)
    --4--
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Zedd and Alessia Cara - Stay")
    print 'Playing Sound 4'
music.SoundId = song4
music:play() 
wait(200)
    --5--
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Coldplay and Chainsmokers - Something Just like this")
        print 'Playing Sound 5'
music.SoundId = song5
music:play() 
wait(200)
    --6--
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Nico and Vinz - Am I Wrong")
    print 'Playing Sound 6'
music.SoundId = song6
music:play() 
wait(200)
    --7--
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Weekend - Starboy")
    print 'Playing Sound 7'
music.SoundId = song7
music:play() 
wait(200)
    --8--
    print 'Playing Sound 8'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Walk the moon - Shut up and Dance")
music.SoundId = song8
music:play() 
wait(200)
--9--
    print 'Playing Sound 8'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Imagine Dragons - Believer")
music.SoundId = song9
music:play() 
wait(200)
--10--
    print 'Playing Sound 8'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Melanie Martinez - Mad Hatter")
music.SoundId = song10
music:play() 

wait(200)
--11--
    print 'Playing Sound 11'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("TwentyonePilots - Lane Boy")
music.SoundId = song11
music:play() 
wait(200)
--11--
    print 'Playing Sound 11'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Chainsmokers - Paris")
music.SoundId = song12
music:play() 
wait(200)
--11--
    print 'Playing Sound 11'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("MØ - Final Song")
music.SoundId = song13
music:play() 
wait(200)
--11--
    print 'Playing Sound 11'
    script.Parent.SurfaceGui.Frame.Visible = true
    script.Parent.SurfaceGui.Frame.Song.Text = ("Fall out boy - Centuries")
music.SoundId = song14
music:play() 

end


0
Check out the player.Chatted event on the wiki. To actually skip the song, you need to start by restructuring the main part of your script as a loop. 2eggnog 981 — 6y
1
Your song system is just too bad to implement this feature effectively. Use a table that stores the ID and name of each song and goes through them one at a time. It will save you probably 100 lines of code and can be expanded with ease lukeb50 631 — 6y
0
Repeating what luke says, make a table with 2 index whatever. The song name and song ID. The code maintainer (You) will have a hard time adding brand spanking new songs to the playlist. httpOmqCxpcake 70 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Players have a event called "Chatted". We can use this event to see what the player typed in the chat and accomplish what we want via it's chatted message.

EDIT: I had a hard time fixing the script but this should work, although it doesn't because the second asset ID doesn't load, so the script breaks because of that and a error message appears then the script can't change to the next song.

local dictonary = {}
dictonary[1] = "http://www.roblox.com/asset/?id=299075527"
dictonary[2] = "http://www.roblox.com/asset/?id=292433682"
dictonary[3] = "http://www.roblox.com/asset/?id=589851184"
dictonary[4] = "http://www.roblox.com/asset/?id=787636293"
dictonary[5] = "http://www.roblox.com/asset/?id=666248225"
dictonary[6] = "http://www.roblox.com/asset/?id=156850138"
dictonary[7] = "http://www.roblox.com/asset/?id=561274893"
dictonary[8] = "http://www.roblox.com/asset/?id=188712851"
dictonary[9] = "http://www.roblox.com/asset/?id=685388224"
dictonary[10] = "http://www.roblox.com/asset/?id=882915526"
dictonary[11] = "http://www.roblox.com/asset/?id=501405545"
dictonary[12] = "http://www.roblox.com/asset/?id=610923182"
dictonary[13] = "http://www.roblox.com/asset/?id=444240273"
dictonary[14] = "http://www.roblox.com/asset/?id=181547615"
dictonary[15] = "http://www.roblox.com/asset/?id=152357361"
dictonary[16] = "http://www.roblox.com/asset/?id=145579822"
dictonary[17] = "http://www.roblox.com/asset/?id=148492408"
dictonary[18] = "http://www.roblox.com/asset/?id=142720946"
dictonary[19] = "http://www.roblox.com/asset/?id=142372565"
dictonary[20] = "http://www.roblox.com/asset/?id=152779074"
dictonary[21] = "http://www.roblox.com/asset/?id=145915908"
dictonary[22] = "http://www.roblox.com/asset/?id=138855854"
dictonary[23] = "http://www.roblox.com/asset/?id=259802648"
dictonary[24] = "http://www.roblox.com/asset/?id=641912399"

print(#dictonary, dictonary[1])
music = Instance.new("Sound", workspace)
music.Pitch = 1
music.Volume = 3
music.Looped = false
music.Name = "Player"
music.SoundId = dictonary[1]
music:Play()

variable = 1
musicwaschanged = false
wait()
while true do
    if variable > 24 then
        variable = 1
    end
    for i = 1, 24 do
        if musicwaschanged == false then
            wait(music.TimeLength - music.TimePosition)
            variable = i
            music:Stop()
            music.SoundId = dictonary[i]
            music:Play()
            print("music changed!")
            print(i)
            print("variable is "..i)
        end
    end
end

game:GetService("Players").PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == "stop" then
            musicwaschanged = true
            print(player.." has requested a skip!")
            variable = variable + 1
            for i = variable, 24 do
                music:Stop()
                music.SoundId = dictonary[i]
                music:Play()
            end
        end
    end)
end)

___________________________

Notes

If one of the song asset IDs don't load, the whole script may break down until it is able to reload again. wait() above while true do makes sure that the asset ID loads as it can.

0
how would i make it so the next song in deck plays if player says stop sweetlittlegirlohhl -22 — 6y
0
It could've been easier to say "skip" but you can change it yourself if you need to! User#18043 95 — 6y
0
It doesnt play the music in game sweetlittlegirlohhl -22 — 6y
0
Make sure it's a server script not local script or module script! User#18043 95 — 6y
View all comments (4 more)
0
I found the error im going to fix it soon just wait! User#18043 95 — 6y
0
I kinda fixed it but it keeps saying the second ID doesn't load? User#18043 95 — 6y
0
when i say stop it doesnt skip the song sweetlittlegirlohhl -22 — 6y
0
I know that but I can't fix it if the second song in the variable table doesn't load, either remove it or change it. The first song works but I don't hear anything. User#18043 95 — 6y
Ad

Answer this question