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

Help with variable?

Asked by
qwrn12 85
8 years ago

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

Log in to vote
0
Answered by
Legojoker 345 Moderation Voter
8 years ago

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.

Ad

Answer this question