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

Help with variable?

the variable Framee is not a valid member of screen gui usally that means the thing doent egsist but it does so is it not reading the variable or what please help here is script

local Framee = "Frame1"
player.Backpack.ChildAdded:connect(function(instance)
	local name=instance.Name
	if name==game.Lighting.E:GetChildren()[1].Name or name==game.Lighting.Q:GetChildren()[1].Name or name==game.Lighting.R:GetChildren()[1].Name or name==game.Lighting.F:GetChildren()[1].Name or name==game.Lighting.G:GetChildren()[1].Name then
		print(instance.Name .. " added to the backpack by item Clone")
	else
    	print(instance.Name .. " " .. Framee -- here it reads it--)
		player.PlayerGui.Invintory.Framee.Frame1.Visible = true
	end
end)

1 answer

✓ Accepted answer

When you write userdata and try to use a string as part of the descendants, you must use brackets and insert the string inside of it like so:

player.PlayerGui.Invintory[Framee].Frame1.Visible = true

Keep in mind this will error if the string Framee was assigned is not found in the userdata object "Invintory." What you've really written is

player.PlayerGui.Invintory.Frame1.Frame1.Visible = true

and I'm not sure if you intended this double Frame1 userdata. You may want to check this, but it could be it's intentional, in which case just ignore this side note.

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