So im basically trying to make some radio thing but it doesnt let me stop the audio thing or put in a new one. If there is a better way to lay this out or if there is something else wrong with this please tell me :] Local Script For ID
local TextButton = script.Parent
TextButton.FocusLost:Connect(function()
local replicated = game:GetService("ReplicatedStorage")
replicated.MusicID:FireServer("MUSICIDENTERED", TextButton.Text)
end)
Local Script to Play Music
local TextButton = script.Parent
TextButton.MouseButton1Click:Connect(function()
local replicated = game:GetService("ReplicatedStorage")
replicated.MusicID:FireServer("PLAY", TextButton.Text)
end)
Local Script To Stop Music
local TextButton = script.Parent
TextButton.MouseButton1Click:Connect(function()
local replicated = game:GetService("ReplicatedStorage")
replicated.MusicID:FireServer("STOP", TextButton.Text)
end)
Server Script
local replicatedStorage = game.ReplicatedStorage
local DJModel = game.Workspace.DJ
local Music = DJModel.MusicID
replicatedStorage.MusicID.OnServerEvent:Connect(function(player, Check, musicID)
if Check == "MUSICIDENTERED" then
if game.Workspace:FindFirstChild("Music") == nil then
local NewSound = Instance.new("Sound")
NewSound.Parent = game.Workspace
NewSound.SoundId = "rbxassetid://"..musicID
NewSound.Name = "Music"
NewSound:Play()
elseif Check == "PLAY" then
if game.Workspace:FindFirstChild("Music") then
if game.Workspace.Music.IsPlaying == false then
game.Workspace.Music:Play()
elseif Check == "STOP" then
if game.Workspace:FindFirstChild("Music") then
if game.Workspace.Model.isPlaying == true then
game.Workspace.Music:Pause()
end
end
end
end
end
end
end)

3 comments
your 'elseifs' are wrong on ur serverscript
I believe focuslost is only available for TextBoxs
You are repeatedly index the same object whish can't possible be different things