local frame = GUI:WaitForChild("Frame")
local OK = frame:WaitForChild("OK")
local VPF = frame:WaitForChild("ViewportFrame")
OK.MouseButton1Click:Connect(function()
frame.Visible = false
end)
game.ReplicatedStorage.FoundEgg.OnClientEvent:Connect(function(eggName)
if game.ReplicatedStorage.Eggs:FindFirstChild(eggName) then
frame.Visible = true
VPF:ClearAllChildren()
local eggClone = game.ReplicatedStorage.Eggs[eggName]:Clone()
eggClone.Parent = VPF
frame.YouFound.Text= "Your Found "..eggName.."!"
local camera = Instance.new("Camera")
camera.Parent = VPF
VPF.CurrentCamera = camera
camera.CFrame = eggClone.CFrame * CFrame.new(0,0,eggClone.Size.z * 1.5)
end
end)```
ServerScriptService script:
```local eggs = game.ReplicatedStorage.Eggs
local spawns = game.Workspace.EggSpawns
while wait (2) do
local eggsTable = eggs:GetChildren()
local randomEgg = eggsTable[math.random(1,#eggsTable)]
local spawnsTable = spawns:GetChildren ()
local randomSpawn = spawnsTable [math.random (1,#spawnsTable)]
local eggClone = randomEgg:Clone ()
eggClone.Parent = game.Workspace.SpawnedEggs
eggClone.Position = randomSpawn.Position + Vector3.new(0,20,0)
eggClone.Anchored = false
eggClone.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr == true then
game.ReplicatedStorage.FoundEgg:FireClient(plr,eggClone.Name)
eggClone:Destroy()
end
end)
end```
local spawns = game.Workspace.EggSpawns
while wait (2) do
local eggsTable = eggs:GetChildren()
local randomEgg = eggsTable[math.random(1,#eggsTable)]
local spawnsTable = spawns:GetChildren ()
local randomSpawn = spawnsTable [math.random (1,#spawnsTable)]
local eggClone = randomEgg:Clone ()
eggClone.Parent = game.Workspace.SpawnedEggs
eggClone.Position = randomSpawn.Position + Vector3.new(0,20,0)
eggClone.Anchored = false
eggClone.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr == true then
game.ReplicatedStorage.FoundEgg:FireClient(plr,eggClone.Name)
eggClone:Destroy()
end
end)
end```
**The scripting inside of ServerScriptService ^**