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

How to make script.Parent.FocusLost:Connect(function() work on a script?

Asked by
jakeovi -1
4 years ago
Edited 4 years ago

I'm working a Speaker Gui that makes you change the music. I know some code but when I try to use script.Parent.FocusLost:Connect(function() on a script it doesn't work. But when I put it in a localscript, it works, but, the song only plays on the players side that has the gui. How do I make it so that it can work on a script? or find a alternative?

script.Parent.FocusLost:Connect(function()
    local text = script.Parent.Text
    workspace.speakers.speaker.Sound.SoundId = "rbxassetid://"..text
    workspace.speakers.speaker2.Sound.SoundId = "rbxassetid://"..text
    workspace.speakers.speaker.Sound:Play()
    workspace.speakers.speaker2.Sound:Play()
end)

Answer this question