Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a text box update?

Asked by 6 years ago
Edited 6 years ago

Hello. I am trying to make server music player GUI. The problem is the text box, where a player enters the audio id is not updating. What I mean is, when I press play audio, it tries to play the default text box text that I had set.

eyy = script.Parent.Parent.TextBox.Text
script.Parent.MouseButton1Click:connect(function()
game.Workspace.Sound.SoundId = ('rbxassetid://'..eyy.Text)
game.Workspace.Sound:Play()
end)

I get this error "Sound Workspace.Sound Failed to load rbxassetid://Enter Audio ID here"

That is the script I have right now. Please tell me what's wrong with it, and how to fix it.

Thanks

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

This is happening because, if you set a variable to the text of the textbox, it'll only store the string of that text at that time. Instead, you should do something like this:

eyy = script.Parent.Parent.TextBox
script.Parent.MouseButton1Click:connect(function()
    game.Workspace.Sound.SoundId = ('rbxassetid://'..eyy.Text)
    game.Workspace.Sound:Play()
end)
0
Thanks! You really helped me. bluestreakejjp 41 — 6y
Ad

Answer this question