I encountered the following error: Try to index null using “WaitForChild”. When I pass an HUD (GUI Interface) argument, the server defines the given argument, but when I pass it to the client, I get this error (in the header) because the value of the passed argument becomes nil:
Printing from the server (argument - GUI - HUD):
Can you please provide the code you are using?
--server
function ActionService:notificationPassport(player, proxPrompt, whotriggred)
local player_pass = game.Players:GetPlayerFromCharacter(proxPrompt.Parent)
local PassportGui = whotriggred.PlayerGui:WaitForChild("ActionsGui").Passport
local HUD = player_pass.PlayerGui:WaitForChild("HUD")
print(player, player_pass, whotriggred, PassportGui, HUD)
self.Client.Passport:Fire(player, player_pass, whotriggred, PassportGui, HUD)
end
function ActionService:KnitInit()
end
function ActionService:KnitStart()
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local hint = script.BillboardGui:Clone()
hint.Parent = char
local proxPrompt = script.ProximityPrompt:Clone()
proxPrompt.Parent = char
proxPrompt.Triggered:Connect(function(player)
if proxPrompt.Parent ~= player.Character then
local whotriggered = player
self.Client.HintInteraction:Fire(player, whotriggered, proxPrompt, hint)
end
end)
end)
end)
end
--client
ActionService.HintInteraction:Connect(function(whotriggred, proxPrompt, hint)
for _, plr in pairs(Players) do
ActionsBillboardGUI.Adornee = proxPrompt.Parent
end
proxPrompt.Enabled = false
hint.Enabled = false
ActionsBillboardGUI.Enabled = true
ActionsBillboardGUI.ActionsMain.CloseButton.Activated:Connect(function()
proxPrompt.Enabled = true
hint.Enabled = true
ActionsBillboardGUI.Enabled = false
end)
for i,v in pairs(ActionsBillboardGUI.ActionsMain.Documents.ActionsScroll:GetChildren()) do
if v:IsA("GuiButton") then
v.Activated:Connect(function()
if v.Name == "Passport" then
ActionController:notificationPassport(proxPrompt, whotriggred)
ActionService.Passport:Connect(function(player_pass, whotriggr, PassportGui, HUD)
print(player_pass, HUD, whotriggr, PassportGui)
local Buttons = HUD:WaitForChild("Announce3", 10).Answers
local yes
local no
yes = Buttons.Yes.Activated:Connect(function()
yes:Disconnect()
no:Disconnect()
HUD:WaitForChild("Announce3", 10):Destroy()
task.wait(0.01)
PassportGui.Title.Text = "PASSPORT ["..player_pass.Name.."]"
PassportGui.LabelsInfo.NumDoc.Text = "2024 "..player_pass.UserId
PassportGui.LabelsInfo.NamePlr.Text = player_pass:WaitForChild("MainPlayer"):WaitForChild("NamePass").Value
PassportGui.LabelsInfo.Surname.Text = player_pass.MainPlayer.SurnamePass.Value
PassportGui.LabelsInfo.PlaceDay.Text = player_pass.MainPlayer.BirthPlace.Value
PassportGui.LabelsInfo.Gender.Text = player_pass.MainPlayer.Gender.Value
PassportGui.LabelsInfo.ArmyTicket.Text = player_pass.MainPlayer.ArmyTicket.Value
PassportGui.LabelsInfo.Law.Text = player_pass.MainPlayer.Lawabiding.Value
PassportGui.Icon.Image = "rbxthumb://type=AvatarHeadShot&id=" ..player_pass.UserId.. "&w=420&h=420"
PassportGui.Visible = true
end)
no = Buttons.No.Activated:Connect(function()
yes:Disconnect()
no:Disconnect()
HUD:WaitForChild("Announce3", 10):Destroy()
end)
end)
local PassportGui = whotriggred.PlayerGui:WaitForChild("ActionsGui").Passport
PassportGui.CloseButton.Activated:Connect(function()
PassportGui.Visible = false
end)
end
end)
end
end
end)
Only all this code is written in the Knit module