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.
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.
local menu = script.Parent.Parent.Parent.PlayerGui.tahcune local selected = menu.selected local plr = script.Parent.Parent.Parent function onObjectSelected(mouse) local t = Instance.new("Part") t.Anchored = true t.FormFactor = 2 t.BottomSurface = "Smooth" t.TopSurface = "Smooth" t.BrickColor = BrickColor.new(Color3.new(0, 0, 0)) t.Transparency = 0.65 t.Position = mouse.Hit.p t.Size = Vector3.new(selected.Value.info.hoverSize.Value.X, selected.Value.info.hoverSize.Value.Y / 2, selected.Value.info.hoverSize.Value.Z) t.Parent = game.Workspace repeat updatePos(mouse, t) until fired == true onPurchase(t) t:Destroy() end function updatePos(mouse, object) t.Position = Vector3.new(math.ceil(mouse.Hit.X), object.Size.Y / 2, math.ceil(mouse.Hit.Z)) wait() end function onPurchase(t) local objects = game.ServerStorage:GetChildren() for i = 1, #objects do if objects[i].Name == selected.Value.Name then local a = objects[i]:Clone() a.Parent = game.Workspace:findFirstChild(plr.Name.."_kit") a:MoveTo(t.Position.X, t.Position.Y / 2, t.Position.Z) a.Name = "base" local b = Instance.new("BoolValue", a.Parent.owned) b.Name = "base" b.Value = true game.ServerStorage:FindFirstChild(plr.Name.."_stats").level = game.ServerStorage:FindFirstChild(plr.Name.."_stats").level + 1 end end end script.Parent.Selected:connect(function(mouse) repeat wait() until menu.selected ~= nil onObjectSelected(mouse) end)
Since you're running this from a HopperBin, and accepts LocalScripts as the only way to execute, you could rather parenting getting LocalPlayer, also I don't understand why you are naming PlayerGui when you are already getting the name?
Getting your player:
local plr = game.Players.LocalPlayer
Finding the PlayerGui:
print(plr.PlayerGui.Name)
EDIT: I think it works anyways.. lol