Juke Box song request script not working

Im making a juke box, and a part outside of it is a click detector, and a gui pops up that lets u put the music id into it. When you click it nothing happens. I’m still really new to scripting so any help is a lot for me.

game.StarterGui["Song ID"] = "gui"
game.StarterGui["Song Id"].TextBox = "id"
local Plr = game.Players.LocalPlayer

local Folder = Instance.new("Folder", Plr)
Folder.Name = "CurrentSong"

local Song = Instance.new("Sound", Folder)
Song.Playing = true

script.Parent.MouseClick:connect(function(Plr)
	if gui.Enable == false then
		gui.Enable = true
	end
	Song.SoundId = "rbxassetid://"..id
	Song:Play()
	end
2 Likes

Are there any errors in the output?

nope, nothing happens at all when u click

Are you doing this client sided? Or server sided?

1 Like

This check is unnecessary, you don’t need to check if it is false, cause if it is true, you would change it to true anyway

1 Like

LocalScripts do not run in Workspace. I would move your script to StarterPlayerScripts or any instance listed here. Also, :connect with a lowercase c is deprecated so I recommend that you use :Connect with a capital C. Also, the property is called Enabled, the d at the end is important, here is a link to the page on the Developer Hub.

2 Likes

On top of @COUNTYL1MITS’s post you aren’t properly referencing the player’s GUI. To get a player’s actual GUI you need to navigate to their own GUI folder.

game.Players.LocalPlayer.PlayerGui
1 Like

yeah I had just noticed that upon editing the script, thank u

ive managed to edit the script and still nothing in the output and nothing happening

game.Players.LocalPlayer.PlayerGui["Song ID"] = "Gui"
game.Players.LocalPlayer.PlayerGui["Song Id"].TextBox = "Id"
local plr = game.Players.LocalPlayer

local Folder = Instance.new("Folder", plr)
Folder.Name = "CurrentSong"

local Song = Instance.new("Sound", Folder)
Song.Playing = true


workspace:WaitForChild("JukeBoxBox"):WaitForChild("ClickDetector").MouseClick:Connect(function(plr)
   Gui.Visible = not Gui.Visible
	Song.SoundId = "rbxassetid://"..Id
	Song:Play()

end)
1 Like

This is your issue. Variables should be defined like this:

local Gui = game.Players.LocalPlayer.PlayerGui["Sound ID"]
2 Likes

upon changing those it still does the exact same thing

I was looking at your updated code. If you are trying to get the server to play whatever ID the player typed into the text box, then I believe you’re going to have to use a Remote Event in order to let the server know that the player typed something in the text box. I’m also fairly new to scripting, so this is just an idea I thought of right off the top of my head.

EDIT: Also in your Id variable, you reference the Textbox, but not the Textbox’s Text.

1 Like