unction EggController:FindEgg()
for i, v in pairs(EggsFolder:GetChildren()) do
if char:FindFirstChild("Humanoid") ~= 0 then
if (char.HumanoidRootPart.Position - v.Part.Position).Magnitude <= MaxMag then
NearEgg = v.Name
end
end
end
end
function EggController:Start()
RunService.RenderStepped:Connect(function()
self:FindEgg()
if NearEgg then -- Checks until NearbyEgg is actually defined.
local Distance = plr:DistanceFromCharacter(EggsFolder:WaitForChild(NearEgg).PrimaryPart.Position)
if Distance < MaxMag then
if NearEgg then
Target.Value = NearEgg
end
else
Target.Value = "None"
end
end
end)
end
For some reason when I die everything stops working can some one help?