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

Why is my Audio Player erroring?

Asked by 10 years ago

For some reason, it isn't working for me, and keeps saying the same error in the Output, the Output says 16:10:30.080 - Players.Player1.PlayerGui.AudioPlayer\.MainScript:43: attempt to index upvalue 'LolDescr' (a nil value) 16:10:30.083 - Stack Begin 16:10:30.084 - Script 'Players.Player1.PlayerGui.AudioPlayer\.MainScript', Line 43 16:10:30.086 - Stack End, but I don't know what I'm doing wrong, and I can't figure out how to fix it, here is the script;

--Audio Player, brought to you by TheeDeathCaster

repeat wait(0)until game.Players.LocalPlayer and game.Players.LocalPlayer:FindFirstChild("PlayerGui", true) and script.Parent and script.Parent:FindFirstChild("Frame", true) and script.Parent.Frame:FindFirstChild("AudioID", true) and script.Parent.Frame:FindFirstChild("Confirm", true) and script.Parent.Frame:FindFirstChild("Description", true) and script.Parent.Frame:FindFirstChild("NameOfAudio")

---------------
--  SETTING  --
---------------
local resetSongOnDeath = false --Set to true if you want the sound to stop onDeath, false if you don't

-----------------
-- Main Script --
-----------------
local plr = game.Players.LocalPlayer
local Frame = script.Parent.Frame
local AudioId = Frame.AudioID
local Confirm = Frame.Confirm
local NameOfAudio = Frame.NameOfAudio
local Desc = Frame.Description
local SongName = nil
local LolDescr = nil
local SongId = nil


if plr:FindFirstChild("NameOfSong") and plr:FindFirstChild("DescOfSong") and plr:FindFirstChild("SongId") then
local SongName = plr.NameOfSong
NameOfAudio.Text = SongName.Value
local LolDescr = plr.DescOfSong
Desc.Text = LolDescr.Value
local SongId = plr.SongId
AudioId.Text = SongId.Value
else
local SongName = Instance.new("StringValue",plr)
SongName.Name = "NameOfSong"
local LolDescr = Instance.new("StringValue",plr)
LolDescr.Name = "DescOfSong"
local SongId = Instance.new("StringValue",plr)
SongId.Name = "SongId"
end

AudioId.FocusLost:connect(function()
local Asset = game:GetService("MarketplaceService"):GetProductInfo(AudioId.Text)
Desc.Text = Asset.Description
LolDescr.Value = Desc.Text
NameOfAudio.Text = Asset.Name
SongName.Value = NameOfAudio.Text
SongId.Value = AudioId.Text
return true
end)

local function CreateAudio(ID)
for i,v in pairs(plr:GetChildren()) do if v:IsA("Sound") then v:Destroy() end end
local Sound = Instance.new("Sound")
Sound.SoundId = "http://www.roblox.com/asset/?id="..ID
Sound.Looped = true
Sound.archivable = false
if resetSongOnDeath then
Sound.Parent = plr.PlayerGui
else
Sound.Parent = plr
end
repeat Sound:Play() wait(2.5) Sound:Stop() wait(.5) Sound:Play() until Sound.IsPlaying
end

Confirm.MouseButton1Down:connect(function()
CreateAudio(AudioId.Text)
AudioId.Text = "Type ID"
end)

plr.Chatted:connect(function(msg)
if msg:lower():sub(1,2) == "a/" then
for i,v in pairs(plr:GetChildren()) do if v:IsA("Sound") then v:Destroy() end end
local Sound = Instance.new("Sound",plr)
Sound.SoundId = "http://www.roblox.com/asset/?id="..msg:sub(3)
Sound.Looped = true
Sound.archivable = false
repeat Sound:Play() wait(2.5) Sound:Stop() wait(.5) Sound:Play() until Sound.IsPlaying
local Azzet = game:GetService("MarketplaceService"):GetProductInfo(msg:sub(3))
Desc.Text = Azzet.Description
LolDescr.Value = Desc.Text
NameOfAudio.Text = Azzet.Name
SongName.Value = NameOfAudio.Text
SongId.Value = AudioId.Text
return true
end
return false
end)

Answer this question