So here is my script:
game.StarterGui.RequestGUI.RequestBox.Play.MouseButton1Click:Connect(function() local Text = game.StarterGui.RequestGUI.RequestBox.Text game.Workspace.Sound.SoundId = "rbxassetid://"..Text game.Workspace.Sound.Playing = true end)
Basically, I'm trying to get it to change the SoundId of a sound in Workspace as well as make it start playing by using the ID the player puts in a textbox.
However, nothing happens when I put in the ID and hit the play button. There are 0 errors in Output and this is in a regular server script.
The problem is that you are doing this all in StarterGui
. The problem is that StarterGui
is simply where stuff gets cloned from (into the Player's PlayerGui
, which is what you should be using instead).
Firstly, make sure your script is inside the ScreenGui
you are using. This will mean that, if the code is right, it will be able to easily access the right ScreenGui
.
Secondly, use your code, but localise it - by that I mean, make it all specific to ScreenGui
it is in, and have it not use other ScreenGui
s (like the one in StarterGui
).
local Gui = script.Parent --> The ScreenGui the script is in local Sound = game.Workspace.Sound -->> You use it more than once so you should make it a variable Gui.RequestBox.Play.MouseButton1Click:Connect(function() Sound.SoundId = "rbxassetid://" ..Gui.RequestBox.Text Sound:Play() end)
Hope I helped!
~TDP