Help me to find the mistake I made

It keeps saying this:
[19:22:32.163 - 1 is not a valid member of Folder] <---- Event is a folder
and there is probably something wrong at this part of script

local Event = Target.Parent:FindFirstChild(“Events”)
for i = 1,#Event:GetChildren() do
local E = Event[i] <–idk why it keeps equal to one instead of object
local Label = script.Parent.Sample:Clone()
Label.Parent = script.Parent.Background
Label.Position =*i,0,0,0)
Label.Name = “Label”…i
Label.Text = “[”…E.Key.Value…"]"…" "…E.Name

I just followed the script at roblox studio wiki.
I have no idea what mistake did I make.

Alright, here’s my goal.

I’m trying to make a gui that appears when your mouse is pointing at the bomb in the picture.

and it should be like this if you are close enough and mouse is pointing to it.

Can you please post an image of your explorer near the script? Without the hiearechy I can’t help :smile:

why? The E keeps equal to one.( a number)

I have read this 4 times and I do not understand what is going on.

Also, fyi, roblox wiki scripts are outdated and you have to actually have to understand them.
You could post your whole explorer and script here and if you, for some reason, are not comfortable with sharing ur explorer then get a friend to help you?

Maybe use pairs/ipairs?

for i, v in pairs (Event:GetChildren()) do

I dunno if this will work, but try it.

it’s kinda difficult to post my explorer

That is not the problem. ( I think )

Not a valid member errors always have to do something with hierarchy or misplaced children.

Umm, screenshot it with snipping tool?
Ok, I see what’s going on. Maybe make Event a table by getting the children of “Events”?

I’m not sure if that’s all the problems

Like this,

local Event = Target.Parent:FindFirstChild(“Events”):GetChildren()

pretend the line 21 is not exist

Try what I suggested above, since u need a table to declare indices on them
Also I think @Mark512345 's method is better than what ur doing, ipairs is better than pairs
Well did u try it?

did you see the line 19? I can’t use it.

Yes, @Mark512345 is right about the pairs. Your problem happened here:

local Event = Target.Parent:FindFirstChild(“Events”)
for i = 1,#Event:GetChildren() do
    local E = Event[i] 

Here, Events is actually the folder object, and is not an array containing its children. You could do what mark said, or change code to:

local Event = Target.Parent:FindFirstChild(“Events”):GetChildren()
for i = 1,#Event do

(Btw @DetailedModuler why did you change the code font to sci-fi? Code are supposed to be monospace.)

1 Like

Yep, what he said.
The point is your trying to access an object called 1 in the folder which does not exist. But, if you use GetChildren(), you can use 1 since it’s indexing a table

Haha bc I moddified it by using

yup lol I modified it bc mono looks not cool to me.
btw what’s the difference between Numeric for loop and Generic for loop in this website
let me try what did mark say.

1 Like

OMG it doesn’t work although I did what he said :frowning:


Yea u just reply to yourself lmao

But the ‘cool’ code is not readable at all :sad:
I had a hard time reading it
The parentheses look like zeros oof


repost my code here

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Service = game:GetService("TweenService")
local info =,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
local Goal1 = {}
Goal1.ImageTransparency = 0
local Goal2 = {}
Goal2.ImageTransparency = 1
local Goal3 = {}
Goal3.TextTransparency = 0
local Goal4 = {}
Goal4.TextTransparency = 1
local Shown = false
local Target = Mouse.Target
if Target ~= nil then
	local Event = Target.Parent:FindFirstChild("Events")
	local Distance = (Target.Position - Player.Character.Head.Position).Magnitude
	if Distance < 5 and Target.Anchored == false and Shown == false and Event then
		Shown = true
		for i,E in ipairs(Event) do
			local E = Event[i]
		local Label = script.Parent.Sample:Clone()
		Label.Parent = script.Parent.Background
		Label.Position =*i,0,0,0)
		Label.Name = "Label"..i
		Label.Text = "["..E.Key.Value.."]".." "..E.Name
		local Tween1 = Service:Create(script.Parent.Background,info,Goal1)
		local Guis = script.Parent.Background:GetChildren()
		for a = 1,#Guis do
			local Gui = Guis[a]
		local Tween2 = Service:Create(Gui,info,Goal3)
	Shown = false
	local Gui = script.Parent.Background
	local Tween3 = Service:Create(Gui,info,Goal2)
	for i = 1,#Gui:GetChildren() do
		local Guis = Gui[i]
		local Tween4 = Service:Create(Guis,info,Goal4)

My script was changed so it is different from the first one.

Can you use the ```lua" then end with the ``.` part because it’s hard to read that and even discouraging.


local instance ="Part")

It appears more readable then

local instance =“Part”)

If you had an error, please post the error and any related materials or we can’t help. And like @fredrick254 said, use ``` to format your code:

your code here

Do indent your code too, so it makes it easy to read.
And, do not spam the thread with unrelated or irrevalent messages. If you have another problem that is related to the title and the first post, you can post it here. Or else, create a new post.