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

Stop a script running from in game?

I have a script located in: Workspace > Music script I want to make a command that I can type in chat to end the program from running. Like end task in task manager. So, I want to be able to type: /musicstop and it stops the music from playing. How would I do this? Mainly, what line of code would end the process?

My script:

--Settings--

song_ID = {324935345,634521493,172590016,695295562,406630973,549408422,453400818,403794513}
randomizer = true -- set to true is a random number, set to false and it is in order

Wait_Time = 95 -- 120 is the max time for a sound/song. Add 5 seconds if you want a buffer between songs

inc = .05 -- this is the increment of which the volume increases/decreases for fade in/out.

--functions and IDs--
asset_ID = "http://www.roblox.com/asset/?id="
function choose(tab) local obj = tab[math.random(1,#tab)] return obj end
function play(s) if s:IsA("Sound") then local o = s.Volume s.Volume = 0 s:play() for i = 0,o,inc do wait() s.Volume = i end s.Volume = o end end
function stop(s) if s:IsA("Sound") then local o = s.Volume for i = o,0,-inc do wait() s.Volume = i end s:stop() s.Volume = o end end
song = Instance.new("Sound",workspace) song.Name = "Hello Cafe's Music Player"


--loop--
counter = 1
if #song_ID > 0 then
while true do
wait()
if randomizer then song.SoundId = asset_ID..""..choose(song_ID) else song.SoundId = asset_ID..""..song_ID[counter] end
play(song)
wait(Wait_Time)
stop(song)
if counter >= #song_ID then counter = 1 else counter = counter + 1 end
end
end

1 answer

I would just suggest using admin, and make sure you can only use admin and then make a thingy where you can stop and play music. I have no idea how you could do it without admin.

2 comments

0

what code would close the script?

0

script:Destroy()

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