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

How am I able to fix my music player cilent side issue?

Asked by 4 years ago
01local input = script.Parent.Parent.Input.Text
02script.Parent.MouseButton1Click:connect(function()
03    local S = Instance.new('Sound',workspace)
04    S.Name = 'Song'
05    S.SoundId = 'rbxassetid://'..input
06    S.Volume = 1
07    S.Pitch = 1
08    S:Play()
09    S:GetPropertyChangedSignal("TimeLength"):Connect(function()
10        if S.TimeLength == 0 then
11            S:Destroy()
12        end
13    end)
14    script.Parent.Parent.Visible = false
15    script.Parent.Parent.Parent.Opener.Visible = true
16    print(S.SoundId)
17end)

Im making a cilent sided music player for my game so people hear their own music and like the script works and all but the issue is the input text isnt being put in it prints out nothing when I use the print method??? Error:

114:51:20.645 - Failed to load sound rbxassetid://: Unable to download sound data

It shows a empty message when I use the print method I don't know how I can put the input to be valid for the button https://gyazo.com/36882bfeeb957fdeb361a347e3be43a5

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Have you tried putting local input = script.Parent.Parent.Input.Text inside the function. I believe what might be happening is it checks the variable once when it is blank (because the text is blank at the start of the GUI) and then does not check it again when you click the MouseButton (ie it uses previous blank value not the text you typed into the input.) The reason for this is because it's not in the function, it has no reason to check the value again.

01script.Parent.MouseButton1Click:connect(function()
02    local input = script.Parent.Parent.Input.Text
03    local S = Instance.new('Sound',workspace)
04    S.Name = 'Song'
05    S.SoundId = 'rbxassetid://'..input
06    S.Volume = 1
07    S.Pitch = 1
08    S:Play()
09    S:GetPropertyChangedSignal("TimeLength"):Connect(function()
10        if S.TimeLength == 0 then
11            S:Destroy()
12        end
13    end)
14    script.Parent.Parent.Visible = false
15    script.Parent.Parent.Parent.Opener.Visible = true
16    print(S.SoundId)
17end)
Ad

Answer this question