Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
thePyxi 179
7 years ago

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)
0
GetChildren does not have any parameters and it will return an array of children belonging to the object. User#5423 17 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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
0
Is dat worthy of a +rep? ;D UltimateRaheem 75 — 7y
0
It still gives me the same error thePyxi 179 — 7y
0
local new = main.VideoList.List:FindFirstChild("Copy"):Clone() --You forgot to add the last bracket for clone(). I've done it for you UltimateRaheem 75 — 7y
0
local guiChildren = vidslist:WaitForChild("Video") --Should be this UltimateRaheem 75 — 7y
View all comments (3 more)
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. UltimateRaheem 75 — 7y
0
Gave me this error now; bad argument #1 to '?' (UDim2 expected, got number) thePyxi 179 — 7y
0
Look, just use lerping UltimateRaheem 75 — 7y
Ad

Answer this question