-
What do you want to achieve? Keep it simple and clear!
I want a textbox that upon pressing enter, will check if the text is a valid audio ID, and submit the ID to another IntValue. -
What is the issue? Include screenshots / videos if possible!
The event does not fire AT ALL, the print statement “fired” does not print. - What solutions have you tried so far? Did you look for solutions on the Developer Hub?
No solutions.
local assetInfo;
local marketservice = game:GetService("MarketplaceService")
local Tbox = script.Parent:WaitForChild("TextBox")
Tbox.FocusLost:Connect(function(entered, inpt)
print("fired")
if entered then
print("ent")
local success, result, assetInfo = pcall(function() -- This prevents any errors from stopping the code
assetInfo = marketservice:GetProductInfo(tonumber(script.Parent.Text), Enum.InfoType.Asset)
end)
if success and assetInfo and assetInfo.AssetType == 3 then -- If there was no errors and the asset type is an audio
print("It's an audio!")
local id = tonumber(script.Parent.Text)
script:FindFirstAncestorWhichIsA("Player").save.killID.Value = id
elseif not success then
warn(result) -- Warn the error message to the output
script.Parent.PlaceholderText = "Invalid ID!"
wait(1)
script.Parent.PlaceholderText = "Insert ID here"
end
end
end)