"FocusLost()" event does not work. (Gui related)

  1. 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.
  2. What is the issue? Include screenshots / videos if possible!
    The event does not fire AT ALL, the print statement “fired” does not print.
  3. 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)

solved, turns out server scripts dont work with this type of interface.

1 Like

Yes, focus is only tracked on the client. You should be using remote events for server-client interactions.

1 Like