Hi, I need help. I was making an simulator and this error showed up: 14:08:45.976 Argument 1 missing or nil - Client - BuyScript:78 Script:

local Player = game.Players.LocalPlayer
local RS = game.ReplicatedStorage
local TS = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
local MS = game:GetService("MarketplaceService")

function rotateEgg(Egg, Rot, NumberTime)
	local TI = TweenInfo.new(NumberTime)
	local Goal = {CFrame = CFrame.Angles(0,0,math.rad(Rot))}
	local Tween = TS:Create(Egg.PrimaryPart, TI, Goal)
	Tween:Play()
end

function eggAnimation(Egg, Result)
	local FrameClone = Player.PlayerGui.UIelements.HatchFrame:Clone()
	local Folder = RS.Pets.Models:FindFirstChild(Result)
	local Type
	for i,v in pairs(Egg["Pets"]) do
		if v.Name == Result then
			Type = v.Type 
		end
	end
	local PetClone = Folder:FindFirstChild(Type):Clone()
	local EggClone = workspace.Eggs:FindFirstChild(script.Parent.Parent.CurrentTarget.Value).EggModel:Clone()
	local Rarity = Folder.Settings.Rarity.Value
	local RarityColor = RS.Pets.Rarities:FindFirstChild(Rarity).Color.Value
	local Camera = Instance.new("Camera", FrameClone)
	local tweenInfo = TweenInfo.new(.35, Enum.EasingStyle.Quad)
	local EggDelay = .075
	game.Lighting.Blur.Size = 26
	FrameClone.CurrentCamera = Camera
	FrameClone.Parent = Player.PlayerGui.EggPreview
	EggClone.Parent = FrameClone
	EggClone:SetPrimaryPartCFrame(CFrame.new(0,0,0) - Vector3.new(0,10,0))
	Camera.CFrame = (EggClone.PrimaryPart.CFrame + Vector3.new(0,10,0)):ToWorldSpace(CFrame.new(0,0,5.5))
	local bringEgg = TS:Create(EggClone.PrimaryPart, tweenInfo, {Position = EggClone.PrimaryPart.Position + Vector3.new(0,10,0)})
	bringEgg:Play()
	wait(.35)
	for i = 1,7 do
		rotateEgg(EggClone, 15, EggDelay)
		wait(EggDelay)
		rotateEgg(EggClone, -15, EggDelay)
		wait(EggDelay)
		EggDelay = EggDelay - .005
	end
	-- 2.78
	rotateEgg(EggClone, 0, EggDelay)	
	wait(EggDelay)
	FrameClone.FlashEffect1:TweenSize(UDim2.new(1.5,0,1.5,2), "Out", "Linear", .2)
	spawn(function()
		for i = 0,1,.1 do
			FrameClone.FlashEffect1.ImageTransparency = i
			wait(.05)
		end
	end)
	wait(.2)
	PetClone.Parent = FrameClone
	PetClone:SetPrimaryPartCFrame(CFrame.new(0,0,0) * CFrame.Angles(0, math.rad(200), 0))
	EggClone:Destroy()
	FrameClone.PetName1.Text = Result
	FrameClone.PetRarity1.Text = Rarity
	FrameClone.PetRarity1.TextColor3 = RarityColor
	wait(1)
	for i = 1,10 do
		game.Lighting.Blur.Size = game.Lighting.Blur.Size - 2.6
		wait(.05)
	end
	FrameClone:TweenPosition(UDim2.new(0,0,1,0), "Out", "Quad", .2)
	wait(.2)
	FrameClone:Destroy()
end

function eggRequest()
	local Egg = require(RS.Pets.Eggs)[script.Parent.Parent.CurrentTarget.Value]
	if Egg ~= nil then
		if script.Parent.Parent.CurrentTarget.Value ~= "None" then
			if (Player.Character.HumanoidRootPart.Position - workspace.Eggs:FindFirstChild(script.Parent.Parent.CurrentTarget.Value).UIanchor.Position).Magnitude <= 10 then
				local Result, Message = RS.RemoteEvents.EggOpened:InvokeServer(script.Parent.Parent.CurrentTarget.Value, "Single")
				if Message == nil and Result ~= "Error" and Result ~= nil then
					eggAnimation(Egg, Result)
				else
					if Message ~= nil then
						if Message ~= "Robux Purchase" then
							print("Error, ".. Message)
						else
							local ProductID = Egg["ProductID"]
							if ProductID ~= nil then
								MS:PromptProductPurchase(Player, ProductID)
							end
						end
					end
				end
			end
		end
	end
end

RS.RemoteEvents.EggOpened.OnClientInvoke = eggAnimation

script.Parent.MouseButton1Click:Connect(function()
	eggRequest()
end)

UIS.InputBegan:connect(function(input,gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.E then
			if UIS:GetFocusedTextBox() == nil then
				eggRequest()
			end
		end
	end
end)


Error line:
local Result, Message = RS.RemoteEvents.EggOpened:InvokeServer(script.Parent.Parent.CurrentTarget.Value, "Single")

6 comments

0

Put your code in a codeblock first.

0

why?

0

cuz idk how, and the error message is on the bottom, so why would i put this script in codeblock?

0

copy and paste this ~~~~~~~~~~~~~~~~~ at the start and end of the script to make it a code block

0

Put it in a codeblock so it is readable, or else no one can help you

0

ok done