I keep getting errors saying that a certain object isn’t there when it really should be, I’ve checked my code and there’s nothing wrong with it. This is starting to get on my nerves.
[quote]PlayerGui is not a valid member of Player
XSize is not a valid member of Frame[/quote]
This can happen if the script runs before the objects are created inside the players. Call :WaitForChild() on objects you really need, works perfectly.
This usually occurs if you run code in a localscript and it’s loaded before the gui is actually loaded.
I always do repeat wait() until game.Players.LocalPlayer.Character
That doesn’t seem to help, except there aren’t any errors in the output.
Can we have the code that is causing the error? This would help greatly in trying to help you with your issue!
Here:
[code]local cansend = true
function onClick()
if cansend == true then
for i, v in pairs(game.Players:GetChildren()) do
if v.Name == script.Parent.Parent.ToBox.Text then
cansend = false
script.Parent.Text = “Sending…”
local nm = game.ReplicatedStorage.NewMail:Clone()
nm.Parent = v.PlayerGui.MailGui.BG.InboxTab
nm.FromLabel.Text = "From: " … game.Players.LocalPlayer.Name
nm.SubjectLabel.Text = script.Parent.Parent.SubjectBox.Text
script.Parent.Text = “Sent”
wait(2)
cansend = true
script.Parent.Text = “Send”
end
end
end
end
script.Parent.MouseButton1Down:connect(onClick)[/code]
That doesn’t seem to help, except there aren’t any errors in the output.[/quote]
That’s because the script stops and waits until the object isn’t nil. You probably have your pathing wrong.
That’s very inefficient for objects other than the players Character. Use :WaitForChild(), it’s better.
That doesn’t seem to help, except there aren’t any errors in the output.[/quote]
That’s because the script stops and waits until the object isn’t nil. You probably have your pathing wrong.[/quote]
Pathing = path to object?
It works fine in edit mode on studio.
Reading through your code, is this in a server script?
WaitForChild never a works for me, so I’ll jut stick with my repeat wait()
That’s very inefficient for objects other than the players Character. Use :WaitForChild(), it’s better.
That doesn’t seem to help, except there aren’t any errors in the output.[/quote]
That’s because the script stops and waits until the object isn’t nil. You probably have your pathing wrong.[/quote]
Pathing = path to object?
It works fine in edit mode on studio.[/quote]
Yes, pathing to object.
How doesn’t it work?
object = object’s parent:WaitForChild(“Object’s Name”)

How doesn’t it work?[/quote]
I don’t know. Whenever I have used it, the script never runs. I know I’m waiting for something that does in time load, but every time without fail it has just failed to work.
That is exactly why I use repeat wait(), not because I’m ignorant to WaitForChild’s existence, it’s just that it has failed the last 20 times I’ve tried using it.
How doesn’t it work?[/quote]
I don’t know. Whenever I have used it, the script never runs. I know I’m waiting for something that does in time load, but every time without fail it has just failed to work.
That is exactly why I use repeat wait(), not because I’m ignorant to WaitForChild’s existence, it’s just that it has failed the last 20 times I’ve tried using it.[/quote]
That’s because the object is nil, and the script waits for it. It does work.
Can I just say, we both somehow messed up the quotes completely. Lol.
Actually you did 
You did something and then it affected my quote as well.
Wait, how can WaitForChild be used to wait for the player’s character to load? Isn’t the character not a child of player?
Confused again.
From experience with WaitForChild, I found that it will keep waiting if an object is added whose name is not what it is waiting for and then if the object’s name is changed to what the WaitForChild is looking for it will not pick it up and contiue waiting.
Could be the reason it doesn’t work for you.