PlayerGui not indexable from a HopperBin?
I finished writing a headache piece of code, only the find out that line 1 didn't work. I have tried to wrap my head around why it won't work, and the only logical explination I came up with is that PlayerGui can't be indexed from a HopperBin (or the Backpack). Here's the problem code, changed a bit from it's previous version.
1 | print (script.Parent.Parent.Parent:FindFirstChild( "PlayerGui" ).Name) |
The script's is heirarchy is as so: game.Players.Player1.Backpack.Tool(HopperBin, not a Tool).Script
It's as if PlayerGui doesn't exist...
Here's all of the code, if it helps.
01 | local menu = script.Parent.Parent.Parent.PlayerGui.tahcune |
02 | local selected = menu.selected |
03 | local plr = script.Parent.Parent.Parent |
05 | function onObjectSelected(mouse) |
06 | local t = Instance.new( "Part" ) |
09 | t.BottomSurface = "Smooth" |
10 | t.TopSurface = "Smooth" |
11 | t.BrickColor = BrickColor.new(Color 3. new( 0 , 0 , 0 )) |
13 | t.Position = mouse.Hit.p |
14 | t.Size = Vector 3. new(selected.Value.info.hoverSize.Value.X, selected.Value.info.hoverSize.Value.Y / 2 , selected.Value.info.hoverSize.Value.Z) |
15 | t.Parent = game.Workspace |
16 | repeat updatePos(mouse, t) until fired = = true |
21 | function updatePos(mouse, object) |
22 | t.Position = Vector 3. new(math.ceil(mouse.Hit.X), object.Size.Y / 2 , math.ceil(mouse.Hit.Z)) |
27 | local objects = game.ServerStorage:GetChildren() |
28 | for i = 1 , #objects do |
29 | if objects [ i ] .Name = = selected.Value.Name then |
30 | local a = objects [ i ] :Clone() |
31 | a.Parent = game.Workspace:findFirstChild(plr.Name.. "_kit" ) |
32 | a:MoveTo(t.Position.X, t.Position.Y / 2 , t.Position.Z) |
35 | local b = Instance.new( "BoolValue" , a.Parent.owned) |
39 | game.ServerStorage:FindFirstChild(plr.Name.. "_stats" ).level = game.ServerStorage:FindFirstChild(plr.Name.. "_stats" ).level + 1 |
45 | script.Parent.Selected:connect( function (mouse) |
46 | repeat wait() until menu.selected ~ = nil |
47 | onObjectSelected(mouse) |