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

Value is not a valid member?

I'm trying to rework my chat a bit, and it's giving me a strange error. It tells me that Value is not a valid member, but it is and it is defined by that earlier


InputService.InputBegan:connect(function(Input, gameProcessed)

	if Input.UserInputType == Enum.UserInputType.Keyboard then
	
		if Input.KeyCode == Enum.KeyCode.Slash and Focused.Value == false then --this line

			Button.BackgroundTransparency = 0.5

			Button:CaptureFocus()
			
			Focused.Value = true

If you need extra help I can provide

5 comments

1

How is Focused defined?

0

We need more in order to help out. We need to know the error, as well as the stuff that goes along with the chunk of code. Like, we need to know what Focused is.

0

Focused is a boolvalue which is a child of the parent of the script, and it is defined as script.Parent.Focused

0

Did you check capitalization and spelling errors?

0

My guess is that you defined a variable 'focused' as being a reference to 'script.Parent.Focused', but here you refer to it as 'Focused' with a capital 'F'. Also, is it a local variable? If so, is it being defined before your InputBegan callback? If not then that might be another reason why you get this error message.

1 answer

✓ Accepted answer

There was an issue I had where I couldn't reference a value via a local script. Here's what I did to fix it, I made sure that when I'm defining the variable, I used :WaitForChild(). In this case, you'd use :WaitForChild(), like so:

Focused = script.Parent:WaitForChild("Focused")

I hope this helps.

Ocula

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