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

Trying to make a audio/Radio Script but it does not seem to work. why?

Asked by 5 years ago

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)
0
your 'elseifs' are wrong on ur serverscript Imperialy 149 — 5y
0
I believe focuslost is only available for TextBoxs Ziffixture 6913 — 5y
0
You are repeatedly index the same object whish can't possible be different things Ziffixture 6913 — 5y

Answer this question