I want to add a gui feature that allows players to change the value in the box and play there own music. How do I make the script find this value from the gui and change the music for that player. This is what I have correct my mistakes so far
MyMusic = game.starterGui.ChangeMusic.textLabel game.starterGui.ChangeMusic.textLabel = (" ")
Moderator note: Please enclose code in code blocks.
Umm that is not going to work because you're accessing the the StarterGui, when you should be accessing the PlayerGui. When a game starts up, everything in the StarterGui gets cloned into the PlayerGui. You can access that by saying, player.PlayerGui.
Also, use a TextBox so users can put in their own link and have a submit button to play the music. Like so:
local plr = game.Players.LocalPlayer -- or whatever you named it local musicGui = plr.PlayerGui.MyMusic -- or whatever you named it local submit = musicGui.Submit -- or whatever you named it local input = musicGui.TextBox -- or whatever you named it local player = musicGui.Sound submit.MouseButton1Click:connect(function() -- Connects the MouseButton1Click event to the function player.SoundId = "rbxassetid://".. input.Text end) --[[ That could work, although it might have some problems. The basis of this was to give you something to go off of. --]]
This isn't working because you are only changing this value to the local player, this doesn't affect the whole server. To do this you could always do something like so:
local Sound = game.ServerStorage.Sound local Gui = --Access the players' GUI here, make sure to put game.Players.LocalPlayer. to access their GUI and just their GUI Sound:Play() Gui.TextLabel = "This song" -- Or whatever you want to insert.
If you want it so that they insert their own value, do something like so:
--Define the same variables as you did in the previous code segment Gui.TextBox.Changed:connect(function() --Connects a function so that if any properties of the TextBox change the value will fire. if Gui.TextBox.Text == "Song" then --You can put any value you want there, and the script will fire when it receives this value Sound:Play() end--Make sure you have this at the end of your if statement end) --Make sure you have this at the end of your script
If you need anything else, feel free to reply back