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

local script cannot find mailbox although mailbox does exist?

I am trying to make a special way to transfer data between scripts! like a postal service. the problem is 2 local scripts are having the same error, they can't find a folder named mailbox. both scripts and folder are in playergui. so I added a screen gui! to test if that would fix it. surprisingly the 2 local scripts could not find the screen gui I added!

script 1 error on line 5

---shortcuts
local GLI = script.Parent.graphical_load_indicator
local black = script.Parent.black_screen
local random = Random.new()
local local_mail_box = script.Parent.Parent.mail_box
local new_mail_1 = Instance.new("StringValue", local_mail_box)
local new_mail_2 = Instance.new("StringValue", local_mail_box)

---set black's transpaerency to 1
black.Transparency = 0
print("gradient is invisble")

---loop until black screen's transparency is 1
repeat
	wait(math.random(1, 10))
---mail a request for local decimal generator
	new_mail_2.Name = "GLI_DG_max_dec"
	new_mail_2.Value = "1"
	new_mail_2.Name = "GLI_DG_min_dec"
	new_mail_2.Value = "0"
	
---apply given decimal to black screen
	
	print(black.Transparency)

until black.Transparency == 1
print("gradient is visible")

---wait some time
wait(math.random(1, 40))

---make "graphical load indicator" value true
GLI.Value = true
print("GLI is shown")

script 2 error on line 2

---shortcuts
local mail_box = script.Parent.Parent.mail_box
local mail = mail_box:GetChildren()
local mail_man = script

	---delivery process
	function delivery(mail)

	---carry all mail to post station (aka mail man's truck)
	mail.Parent = mail_man

	---find out who it goes to


	---deliver the mail

end

---check for mail
mail_box.ChildAdded:Connect(delivery)

they both get this specific message: mail_box is not a valid member of PlayerGui "Players.jeremqpmfpi.PlayerGui" - Client

1 answer

✓ Accepted answer

maybe do

local Player = game.Players.LocalPlayer
local Mailbox =  Player.PlayerGui:WaitForChild("mail_box")

instead

1 comment

0

if it doesn't work maybe its because the mailbox is in a screenGui instead

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