So I'm trying to create a server script that plays audio to the whole server, I've tried this on a local script, just testing to see if at least one player can hear the audio. It worked perfectly on the local script, I tried pasting the same script into a server script and it didn't play anything, all it did was insert the text rbxassetid:// into sound id.
Here's the code:
-- \\ CONTROL SCRIPT local textbox = script.Parent.TextBox local textbutton = script.Parent.TextButton textbutton.MouseButton1Click:Connect(function() tostring(textbox.Text) game.Workspace.Sound.SoundId = "rbxassetid://"..textbox.Text end)
Can someone help me out? Thanks! :)
The reason why your sound id is not changing is that the textbox text does not actually change on the server when you change it locally. In other words, the server cannot read the changes that the client makes to the textbox, so therefore it would just be empty on the server.
To fix this, you could either use a RemoteEvent or a RemoteFunction. I would recommend using a RemoteEvent because RemoteFunctions can cause infinite yielding (depending on how you handle it), so using a RemoteEvent is the safer route.
Have a local script send in the textbox's text to the server when you click the button (fire a RemoteEvent), and then in the server script that catches the event, take the information that the client sent you and apply it how you did it in your code.
1st Add a Sound in the workspace and add a script and name it Music then put this script into the
Music
local Sound1 = 0
local Sound2 = 0
local Sound3 = 0
local Sound4 = 0
local Sound5 = 0
local Sound6 = 0
local Sound7 = 0
local Sound8 = 0
local Sound9 = 0
local Sound10 = 0
local Sound11 = 0
local Sound12 = 0
local Sound13 = 0
local Music = game.Workspace.Sound
wait(5)
while true do
Music.SoundId = "rbxassetid://"..Sound1
Music:Play()
wait(170)
Music.SoundId = "rbxassetid://"..Sound2
Music:Play()
wait(110)
Music.SoundId = "rbxassetid://"..Sound3
Music:Play()
wait(177)
Music.SoundId = "rbxassetid://"..Sound4
Music:Play()
wait(1)
Music.SoundId = "rbxassetid://"..Sound5
Music:Play()
wait(120)
Music.SoundId = "rbxassetid://"..Sound6
Music:Play()
wait(50)
Music.SoundId = "rbxassetid://"..Sound7
Music:Play()
wait(49)
Music.SoundId = "rbxassetid://"..Sound8
Music:Play()
wait(160)
Music.SoundId = "rbxassetid://"..Sound9
Music:Play()
wait(160)
Music.SoundId = "rbxassetid://"..Sound10
Music:Play()
wait(160)
Music.SoundId = "rbxassetid://"..Sound11
Music:Play()
wait(160)
Music.SoundId = "rbxassetid://"..Sound12
Music:Play()
wait(160)
Music.SoundId = "rbxassetid://"..Sound13
Music:Play()
wait(60)
end
You can change the 0 to the music ids you want and the wait() for how long the sound is.