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

Attempt to index field 'Position' (a nil value) How do I fix this?

I'm trying to make a set of GUIs move down when there is a new GUI being placed into the frame. Line 8, is where it fails and it's giving me a nil value for the position. I don't know how to fix this...

local new = main.VideoList.List:FindFirstChild("Copy"):Clone()
local move = main.VideoList.List.MoveDown --Value of 56
local vidslist = main.VideoList.List
local copyGui = main.VideoList.List.Copy
local guiChildren = vidslist:GetChildren("Video")
	
if guiChildren then
	guiChildren.Position = UDim2.new(0,0,0,guiChildren.Position.Y.Offset + move.Value)
end
new.Parent = main.VideoList.List
new.Position = UDim2.new(0,0,0,0)

1 comment

0

GetChildren does not have any parameters and it will return an array of children belonging to the object.

1 answer

When it comes to moving and resizing guis I'd recommend using tweening. The official ROBLOX Wiki covers it all. But here's your answer anyway:

if guiChildren then
          guiChildren.Position = guiChildren.Position.Y.Offset + UDim2.new(0, 0, 0, move.Value)
end

7 comments

0

Is dat worthy of a +rep? ;D

0

It still gives me the same error

0

local new = main.VideoList.List:FindFirstChild("Copy"):Clone() --You forgot to add the last bracket for clone(). I've done it for you

0

local guiChildren = vidslist:WaitForChild("Video") --Should be this

0

Anyway I've pretty much answered this as I've fixed the output from saying what your title says. So you can make this post answered now.

0

Gave me this error now; bad argument #1 to '?' (UDim2 expected, got number)

0

Look, just use lerping

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