Anyone know how to fix this?

i changed the code a bit
I think it will fix it

I am trying to solve the latest error they were getting which is the warning

1 Like

No it wont due to this line:

playerHatchDebounce[player]

Please someone can understand what Im saying? OP is trying to find a key that doesnt exist in that table… a Table that is based on Player’s keys, and that Table is literally empty…

How script would find that Key if it doesnt even exist? it never got created by the script…

1 Like

i created a remote thats what that is

It can because if you put in the script
playerHatchDebounce[player] = true
then it will create a key
and if u say
playerHatchDebounce[player] = false
then it will create or change the key

here is the script for the yield:

local runService = game:GetService("RunService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local tweenService = game:GetService("TweenService")

local eggs = workspace:WaitForChild("Mainfolder_workspace"):WaitForChild("Eggs")
local remotes = replicatedStorage:WaitForChild("Remotes")
local pets = replicatedStorage:WaitForChild("Pets")

local player = players.LocalPlayer
local eggSystemSS = player:WaitForChild("PlayerGui"):WaitForChild("EggViewerSystem")
local eggViewport = eggSystemSS:WaitForChild("EggViewer")

local function hatchEgg(eggName, chosenPet)
	for _, v in pairs(player.PlayerGui:GetChildren()) do
		if v: IsA("ScreenGui") and v ~= eggSystemSS then
			v.Enabled = false
		end
	end
	eggSystemSS.Enabled = true
	for _, v in pairs(eggViewport:GetChildren()) do
		if v: IsA("Camera") or v:IsA("BasePart") or v:IsA("Model") then
			v:Destroy()
		end
	end
	eggViewport.Size = UDim2.fromScale(0, 0)
	local eggMesh = eggs:FindFindFirstChild(eggName):Clone()
	eggMesh.Parent = eggViewport
	eggMesh.CFrame = CFrame.new(0, 0, 0)
	local camera = Instance.new("Camera")
	camera.Parent = eggViewport
	camera.CFrame = CFrame.new(0, 0, 4)
	eggViewport.CurrentCamera = camera
	tweenService:Create(eggViewport, TweenInfo.new(0.7), {Size = UDim2.new(0.267, 0,0.437, 0)}):Play()
	task.wait(0.7)
	for i = 1, 4 do
		tweenService:Create(eggViewport, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Rotation = 20}):Play()
		task.wait(0.3)
		tweenService:Create(eggViewport, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Rotation = -20}):Play()
		task.wait(0.3)
	end
	tweenService:Create(eggViewport, TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Rotation = 0}):Play()
	task.wait(0.3)
	tweenService:Create(eggViewport, TweenInfo.new(0.7), {Size = UDim2.fromScale(0, 0)}):Play()
	task.wait(0.3)
	for _, v in pairs(eggViewport:GetChildren()) do
		if v: IsA("Camera") or v:IsA("BasePart") or v:IsA("Model") then
			v:Destroy()
		end
	end
	local petModel = pets:FindFirstChild(chosenPet.petName):Clone()
	petModel:Pivotto(CFrame.new(0, 0, 0))
	petModel.Parent = eggViewport
	local cameraPet = Instance.new("Camera")
	cameraPet.Parent = eggViewport
	cameraPet.CFrame = CFrame.new(0, 0, -3.3) * CFrame.Angles(0, math.rad(180), 0)
	eggViewport.currentcamera = cameraPet
	tweenService:Create(eggViewport, TweenInfo.new(0.7), {Size = UDim2.new(0.267, 0,0.437, 0)}):Play()
	eggViewport.NameLabel.Text = chosenPet.petname
	eggViewport.NameLabel.Visible = true
	eggViewport.RarityLabel.Text = chosenPet.Rarity
	eggViewport.RarityLabel.Visible = true
	task.wait(1.5)
	tweenService:Create(eggViewport, TweenInfo.new(0.3), {Size = UDim2.fromScale(0, 0)}):Play()
	task.wait(0.3)
	eggViewport.NameLabel.Visible = false
	eggViewport.RarityLabel.Visible = false
	for _, v in pairs(player:WaitForChild("PlayerGui"):GetChildren()) do
		if v: IsA("ScreenGui") and v ~= eggSystemSS then
			v.Enabled = true
		end
	end
end

remotes:WaitForChild("HatchEgg").OnClientEvent:Connect(hatchEgg)

Can you add this right after line 13 print(“Works!”), and filter the output console with Works! The yield error might be caused because the WaitForChild function isn’t returning fast enough.

A table index (key) can be any datatype (Instance, function, boolean, number, string, etc.). In this case, I assume that you want a player-only debounce system that will limit the player from hatching another egg for some time since there is no local player in a server-side script, which runs on the Roblox server and cannot know which player you meant. Therefore, you need to specify the player. in playerHatchDebounce[player]
It would debounce the server, so consider changing every playerHatchDebounce[player] to playerHatchDebounce[Player]

ok so do you know how i would do that?

didnt work:
image

still says:

to do with this:

Please keep most of your info within like 1-2 messages, so send entire code instead of screenshots of it, it makes it very hard to read.

Can you check if the path (game.StarterGui.EggViewerSystem) is actually there (not nil/null)? If it is, add this: print(player.PlayerGui:GetChildren()) before line 11 and show the output.

Change every instance of playerHatchDebounce[player] to playerHatchDebounce[Player] in the first script that you sent.

If it isn’t, then make the Instance in the path or remove that variable and change every usage of it.

Im just trying to make it hatch a pet like pet sim x

Ok but I need answers to help you

Can you also help me? Is it good to use TweenService for checking collisions?

Sorry for not responding. I didn’t respond because I don’t know how to fix this. I usually make my tweens with loops and don’t use them other than for GUI.