Why do I get this error [ attempt index nil with 'ScreenGui'

I get on an error, on line three. But I’m not sure why!

image
It says index nil with screengui. well, duh.
where have I gone wrong here?

Converted = {
['ScreenGui'] = {Instance.new('ScreenGui'), Parent = game.Players.LocalPlayer.PlayerGui},
['Frame'] = {Instance.new('Frame'), Parent = Converted['ScreenGui']},
}

I don’t understand. Can I not access a table while I’m coding inside of that same table?

Your setting the not setting the parent. You’re assigning a variable called Parent. and I don’t see you using it, but it’s probably a snippet. I would try something like this:

Converted = {
	['ScreenGui'] = {Instance.new('ScreenGui', game.Players.LocalPlayer.PlayerGui)},
}

Converted['Frame'] = {Instance.new('Frame', Converted['ScreenGui'][1])}
1 Like

I don’t believe that you can access the dictionary when you are initialising it.
Consider doing something like this instead:

Converted = {}
Converted['ScreenGui'] = {Instance.new('ScreenGui'), Parent = game.Players.LocalPlayer.PlayerGui},
Converted['Frame'] = {Instance.new('Frame'), Parent = Converted['ScreenGui']},

1 Like

@JAcoboiskaka1121
@SeargentAUS

both of your solutions did work, thanks for the help and I also had to adjust it a bit but it works

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.