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

Cannot use the function ReleaseFocus?

So I am making a plugin to find hidden properties that are not in properties panel here. So, I am making a text box you need to type a value in to edit the property, but it errors here.

gui.Frame.PropertyValue.ReleaseFocus:Connect(function()
	if forceunfocus then --Tells if another part of this script forced the user to release the text box, if the property name is invalid.
		forceunfocus = false
		return
	end
	game.Selection:Get()[1][gui.Frame.PropertyName.Text] = gui.Frame.PropertyValue.Text
end)

It errors Plugin_1021195314.HiddenProperties.Script:48: attempt to index field 'ReleaseFocus' (a function value). I am not trying to store anything the function returns or anything, so I am confused as to why I get this error. If you need the whole script for some reason, here is the whole one.

plugin:Activate(true)

local button = plugin:CreateToolbar('Find Hidden Properties'):CreateButton(
	'Find Hidden Property',
	'Click to find and edit a hidden property not shown in properties tab!',
	''
)

local active = false

button.Click:Connect(function()
	active = not active
	
	button:SetActive(active)
	
	if active then
		local validproperty = false
		local gui = script.Parent.FindHidden:Clone()
		gui.Parent = game.CoreGui
		gui.Frame.PropertyName.FocusLost:Connect(function()
			local s, m = pcall(function()
				local value = game.Selection:Get()[1][gui.Frame.PropertyName.Text]
			end)
			if not s then
				gui.Frame.PropertyValue = ''
				gui.Frame.Warning.Text = 'The current item selected does not have this property!'
				wait(1)
				gui.Frame.Warning.Text = ''
				return
			end
			
			validproperty = true
			gui.Frame.PropertyValue.Text = game.Selection:Get()[1][gui.Frame.PropertyName.Text]
		end)
		
		local forceunfocus = false
		gui.Frame.PropertyValue.Focused:Connect(function()
			if not validproperty then
				forceunfocus = true
				gui.Frame.PropertyValue:ReleaseFocus()
				gui.Frame.Warning.Text = 'No valid property selected!'
				wait(1)
				gui.Frame.Warning.Text = ''
				return
			end
		end)
		
		gui.Frame.PropertyValue.ReleaseFocus:Connect(function()
			if forceunfocus then
				forceunfocus = false
				return
			end
			game.Selection:Get()[1][gui.Frame.PropertyName.Text] = gui.Frame.PropertyValue.Text
		end)
	elseif game.CoreGui:FindFirstChild('FindHidden') then
		game.CoreGui.FindHidden:Destroy()
	end
end)

Another note:When I click the button, the GUI does not show up, even though the error is past when I set the GUI's parent.

1 answer

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