So im trying to make each pet have a unique id and when you open an egg, it sends a value to the client.
The error:
Players.cadengamer11111.PlayerGui.Inventory.Inventory.GuiScript:28: invalid argument #3 (string expected, got nil)
Ive tried doing a bunch
The serverscript:
local template = script:WaitForChild("Template")
local inv = script.Parent
local sf = script.Parent:WaitForChild("ScrollingFrame")
local open = script.Parent.Parent:WaitForChild("OpenInv").ImageButton
local addPet = game.ReplicatedStorage.RemoteEvents:WaitForChild("AddPet")
local removePet = game.ReplicatedStorage.RemoteEvents:WaitForChild("RemovePet")
local isOpen = false
local function addToFrame(pet,idiot)
print(idiot)
local newTemplate = template:Clone()
newTemplate.Name = pet.Name
newTemplate.PetName.Value = pet.Name
newTemplate.Parent = sf
local newPet = pet:Clone()
newPet.Parent = newTemplate.ViewportFrame
local camera = Instance.new("Camera")
camera.CFrame = CFrame.new(newPet.Position + (newPet.CFrame.lookVector * 1.65),newPet.Position)
camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(-0.03, -0.025, 0.2)
camera.Parent = newTemplate.ViewportFrame
newTemplate.ViewportFrame.CurrentCamera = camera
newTemplate.ID.Value = idiot
local newSelectBox = Instance.new("SelectionBox")
newSelectBox.Color3 = Color3.new(0,0,0)
end
addPet.OnClientEvent:Connect(function(pet)
addToFrame(pet)
end)
open.MouseButton1Up:Connect(function()
if isOpen == false then
isOpen = true
inv.Visible = true
inv.Position = UDim2.new(0.094,0,0.19,0)
inv:TweenPosition(UDim2.new(0.094,0,0.155), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.2)
wait(0.3)
inv.Position = UDim2.new(0.094,0,0.155)
else
isOpen = false
inv.Visible = false
inv.Position = UDim2.new(0.094,0,0.19,0)
end
wait(0.3)
end)
My client script which is inside the gui with a template gui inside of it:
local template = script:WaitForChild("Template")
local inv = script.Parent
local sf = script.Parent:WaitForChild("ScrollingFrame")
local open = script.Parent.Parent:WaitForChild("OpenInv").ImageButton
local addPet = game.ReplicatedStorage.RemoteEvents:WaitForChild("AddPet")
local removePet = game.ReplicatedStorage.RemoteEvents:WaitForChild("RemovePet")
local isOpen = false
local function addToFrame(pet,id)
local newTemplate = template:Clone()
newTemplate.Name = pet.Name
newTemplate.PetName.Value = pet.Name
newTemplate.Parent = sf
local newPet = pet:Clone()
newPet.Parent = newTemplate.ViewportFrame
local camera = Instance.new("Camera")
camera.CFrame = CFrame.new(newPet.Position + (newPet.CFrame.lookVector * 1.65),newPet.Position)
camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(-0.03, -0.025, 0.2)
camera.Parent = newTemplate.ViewportFrame
newTemplate.ViewportFrame.CurrentCamera = camera
newTemplate.ID.Value = id
local newSelectBox = Instance.new("SelectionBox")
newSelectBox.Color3 = Color3.new(0,0,0)
end
addPet.OnClientEvent:Connect(function(pet)
addToFrame(pet)
end)
open.MouseButton1Up:Connect(function()
if isOpen == false then
isOpen = true
inv.Visible = true
inv.Position = UDim2.new(0.094,0,0.19,0)
inv:TweenPosition(UDim2.new(0.094,0,0.155), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.2)
wait(0.3)
inv.Position = UDim2.new(0.094,0,0.155)
else
isOpen = false
inv.Visible = false
inv.Position = UDim2.new(0.094,0,0.19,0)
end
wait(0.3)
end)