local A1 = game.Workspace.Eggs:FindFirstChild('A')
local B2 = game.Workspace.Eggs:FindFirstChild('B')
local C3 = game.Workspace.Eggs:FindFirstChild('C')
local D4 = game.Workspace.Eggs:FindFirstChild('D')
local E5 = game.Workspace.Eggs:FindFirstChild('E')
local F6 = game.Workspace.Eggs:FindFirstChild('F')
local G7 = game.Workspace.Eggs:FindFirstChild('G')
local H8 = game.Workspace.Eggs:FindFirstChild('H')
local I9 = game.Workspace.Eggs:FindFirstChild('I')
local J10 = game.Workspace.Eggs:FindFirstChild('J')
A1.ProximityPrompt.Triggered:Connect(function()
if A1 then
A1:Destroy()
end
end)
B2.ProximityPrompt.Triggered:Connect(function()
if B2 then
B2:Destroy()
end
end)
C3.ProximityPrompt.Triggered:Connect(function()
if C3 then
C3:Destroy()
end
end)
D4.ProximityPrompt.Triggered:Connect(function()
if D4 then
D4:Destroy()
end
end)
E5.ProximityPrompt.Triggered:Connect(function()
if E5 then
E5:Destroy()
end
end)
F6.ProximityPrompt.Triggered:Connect(function()
if F6 then
F6:Destroy()
end
end)
G7.ProximityPrompt.Triggered:Connect(function()
if G7 then
G7:Destroy()
end
end)
H8.ProximityPrompt.Triggered:Connect(function()
if H8 then
H8:Destroy()
end
end)
I9.ProximityPrompt.Triggered:Connect(function()
if I9 then
I9:Destroy()
end
end)
J10.ProximityPrompt.Triggered:Connect(function()
if J10 then
J10:Destroy()
end
end)
Everything looks good for the path, so you know the issue isn’t there. Try to think of other things that might be causing this. Debugging is a big part of learning to program. Try to put a print statement to print out A1 and see if the hypothesis of it being nil is correct?
Then try to think of other things that might be causing it. Could the part not be spawned in yet?
Everything looks fine… What exactly do you mean by “But only some are destroying and some are not.”. I put your script into a place and it works perfectly fine for me. egg.rbxl (37.6 KB)
This might be because prior the player’s death, they already collected some eggs. When their character resets or dies, the local script within it will clone itself into the new respawned character model and rerun the same script again. When the new script tries to get proximity prompts of the eggs the player has collected, it would result in nil. That’s why.