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 3 years ago
local input = script.Parent.Parent.Input.Text
script.Parent.MouseButton1Click:connect(function()
    local S = Instance.new('Sound',workspace)
    S.Name = 'Song'
    S.SoundId = 'rbxassetid://'..input
    S.Volume = 1
    S.Pitch = 1
    S:Play()
    S:GetPropertyChangedSignal("TimeLength"):Connect(function()
        if S.TimeLength == 0 then
            S:Destroy()
        end
    end)
    script.Parent.Parent.Visible = false
    script.Parent.Parent.Parent.Opener.Visible = true
    print(S.SoundId)
end)

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:

14: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 3 years ago
Edited 3 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.

script.Parent.MouseButton1Click:connect(function()
    local input = script.Parent.Parent.Input.Text
    local S = Instance.new('Sound',workspace)
    S.Name = 'Song'
    S.SoundId = 'rbxassetid://'..input
    S.Volume = 1
    S.Pitch = 1
    S:Play()
    S:GetPropertyChangedSignal("TimeLength"):Connect(function()
        if S.TimeLength == 0 then
            S:Destroy()
        end
    end)
    script.Parent.Parent.Visible = false
    script.Parent.Parent.Parent.Opener.Visible = true
    print(S.SoundId)
end)


Ad

Answer this question