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)

3 comments
I see what you're getting at, but I need to be able to access ServerStorage with the script, and LocalScripts can't
How can your code access ServerStorage then? Running ServerScripts can't work on HopperBin as it was disabled because of exploits.
Crud. I forgot to test this in a live game. Thanks, I'll rewrite to work from a tool!