Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I can't seem to put my audio name to my TEXT gui "Argument 1 missing or nil" ?

local sid = script.Parent.Parent.Parent.music.SoundId
while wait() do
	local asset = game:GetService("MarketplaceService"):GetProductInfo(tonumber(sid:sub(14)))
    script.Parent.Text = asset.Name
end

In the output, it says "Argument 1 missing or nil" i'm currently trying to make it so when an audio plays with a specific id, it puts the audio name to the text.

1 comment

0

Is SoundId nil at any point in time? If so you'll need to check that before trying to load asset

1 answer

Like clc02 said, your parents may be wrong or something is nil, so check your output for errors.

local mother = script.Parent.Parent.Parent
local child = mother:WaitForChild("music")
-- Use WaitForChild() on children
local mps = game:GetService("MarketplaceService")

local function set()
	local id = string.match(child.SoundId, '%d+')
	-- %d is the pattern for numbers
		-- will return the first number found
	-- adding a + sign matches the group of numbers
	local asset = mps:GetProductInfo(id)
	script.Parent.Text = asset.Name
end

child:GetPropertyChangedSignal('SoundId'):Connect(function()
	-- Fires when the SoundId property changes
	set()
end)

set()
-- set the first time the script loads

1 comment

0

Doesnt seem to work, it still says Argument 1 missing or nil

This discussion is preserved as it was. New answers, comments, and votes are closed.