Argument 1 missing or nil

Running a remote script which labels the name of the shop including the player and a camera, however it says the name of the shop is nil or just isn’t there, would anyone know why?

image

On line 32 is the error :
Local Script :

if not game.Players.LocalPlayer.Character then game.Players.LocalPlayer.CharacterAdded:Wait() end

local firstevent = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("NewShop")
local currentCam = workspace.CurrentCamera
local tweenService = game:GetService("TweenService")
	
function Invisible(TurnsInvisible)
	if TurnsInvisible == true then
		for i,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
			if v:IsA("MeshPart") or v:IsA("Part") or v:IsA("Decal") then
				if v ~= game.Players.LocalPlayer.Character.PrimaryPart then
					v.Transparency = 1
				end
			elseif v:IsA("Accessory") then
					v:FindFirstChildOfClass("MeshPart").Transparency = 1
			end
		end
	else
		for i,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
			if v:IsA("MeshPart") or v:IsA("Part") or v:IsA("Decal") then
				if v ~= game.Players.LocalPlayer.Character.PrimaryPart then
					v.Transparency = 0
				end
			elseif v:IsA("Accessory") then
					v:FindFirstChildOfClass("MeshPart").Transparency = 0
			end
		end
	end
end

firstevent.OnClientEvent:Connect(function(toolCamera,plr,shop)
	local ShopGui = game:GetService("ReplicatedStorage"):WaitForChild("Shops"):WaitForChild(shop):WaitForChild("Shop")
	local proximityprompt = toolCamera.Parent.ProximityPromptHolder:FindFirstChild("ProximityPrompt")
	proximityprompt.Enabled = false
	currentCam.CameraType = Enum.CameraType.Scriptable
	task.spawn(Invisible,true)
	local camSwitch = tweenService:Create(currentCam, TweenInfo.new(1.75), {CFrame = toolCamera.CFrame})
	camSwitch:Play()
	if not game.Players.LocalPlayer.PlayerGui:FindFirstChild("Shop") then
	local gui = ShopGui:Clone()
	gui.Parent = script.Parent.Parent
	end
end)

ServerScript :

local proximityprompt = script.Parent
local event = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("NewShop")

proximityprompt.Triggered:Connect(function(plr)
	local toolCamera = script.Parent.Parent.Parent:FindFirstChild("Camera")
	local shop = workspace.Shop.HotDogStand.HotDogStandSans.Name
	event:FireClient(plr,toolCamera,shop)
end)

Help would be greatly appreciated thank you!

1 Like

Maybe try separating the :WaitForChild()s into different variables. So 1 WaitForChild() per variable.

2 Likes

Since you are already waiting for “Shops” there is no need to wait for the children of it since they have loaded.

1 Like

Like this?

LocalScript

if not game.Players.LocalPlayer.Character then game.Players.LocalPlayer.CharacterAdded:Wait() end

local firstevent = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("NewShop")
local currentCam = workspace.CurrentCamera
local tweenService = game:GetService("TweenService")
local ShopFolder = game:GetService("ReplicatedStorage"):WaitForChild("Shops")

function Invisible(TurnsInvisible)
	if TurnsInvisible == true then
		for i,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
			if v:IsA("MeshPart") or v:IsA("Part") or v:IsA("Decal") then
				if v ~= game.Players.LocalPlayer.Character.PrimaryPart then
					v.Transparency = 1
				end
			elseif v:IsA("Accessory") then
					v:FindFirstChildOfClass("MeshPart").Transparency = 1
			end
		end
	else
		for i,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
			if v:IsA("MeshPart") or v:IsA("Part") or v:IsA("Decal") then
				if v ~= game.Players.LocalPlayer.Character.PrimaryPart then
					v.Transparency = 0
				end
			elseif v:IsA("Accessory") then
					v:FindFirstChildOfClass("MeshPart").Transparency = 0
			end
		end
	end
end

firstevent.OnClientEvent:Connect(function(toolCamera,plr,shop)
local ShopGui = ShopFolder[shop]:WaitForChild("Shop")
	local proximityprompt = toolCamera.Parent.ProximityPromptHolder:FindFirstChild("ProximityPrompt")
	proximityprompt.Enabled = false
	currentCam.CameraType = Enum.CameraType.Scriptable
	task.spawn(Invisible,true)
	local camSwitch = tweenService:Create(currentCam, TweenInfo.new(1.75), {CFrame = toolCamera.CFrame})
	camSwitch:Play()
	if not game.Players.LocalPlayer.PlayerGui:FindFirstChild("Shop") then
	local gui = ShopGui:Clone()
	gui.Parent = script.Parent.Parent
	end
end)
1 Like

or this:

local RP = game:GetService("ReplicatedStorage")

local ShopGui = RP:WaitForChild("Shops"):FindFirstChild(shop).Shop
1 Like

Still gives the same error sadly that argument 1 is missing or nil on the same line.

1 Like

Can you show replicated storage and what your trying to access?

1 Like

image

can you scroll down a bit please

Everything in there

try this:

local RP = game:GetService("ReplicatedStorage")

local ShopGui = RP:WaitForChild("Shops").HotDogStandSans.Main

So what is happening now? Is it working?