Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RunService = game:GetService("RunService")
- local Players = game:GetService("Players")
- local TweenService = game:GetService("TweenService")
- local UserInputService = game:GetService("UserInputService")
- local MarketPlaceService = game:GetService("MarketplaceService")
- local Player = Players.LocalPlayer
- local PlayerGui = Player.PlayerGui
- local Module3D = require(ReplicatedStorage.Libs.Module3D)
- local Gui = PlayerGui:WaitForChild("Eggs")
- local EggBillboardsFolder = Gui.EggBillboards
- local ChaosFolder = ReplicatedStorage:WaitForChild("Chaos")
- local Eggs = workspace:WaitForChild("Eggs")
- local MaxDisplayDistance = 15
- local CanHatch = false
- local IsHatching = false
- local HatchOneConnection = nil
- local CannotOpenBillboard = false
- local Cooldown = false
- local function AnimateBillboard(Billboard: BillboardGui, Open: boolean)
- if Open == true then
- local Tween = TweenService:Create(Billboard, TweenInfo.new(0.1), {Size = UDim2.fromScale(5, 7)})
- Tween:Play()
- else
- local Tween = TweenService:Create(Billboard, TweenInfo.new(0.1), {Size = UDim2.fromScale(0, 0)})
- Tween:Play()
- Tween.Completed:Connect(function()
- task.wait(0.2)
- Billboard.Enabled = false
- end)
- end
- task.wait(0.5)
- end
- local function ToggleAllScreenGuis(Bool: boolean)
- if Bool == false then
- for i, v in PlayerGui:GetChildren() do
- if v.Name ~= "Eggs" then
- v.Enabled = false
- end
- end
- else
- for i, v in PlayerGui:GetChildren() do
- if v.Name == "Main" or v.Name == "Eggs" then
- v.Enabled = true
- end
- end
- end
- end
- local function DisableAllBillboards()
- CannotOpenBillboard = true
- for i, v in pairs(EggBillboardsFolder:GetChildren()) do
- if v:IsA("BillboardGui") then
- AnimateBillboard(v, false)
- end
- end
- end
- local function EnableAllBillboards()
- CannotOpenBillboard = false
- for i, v in pairs(EggBillboardsFolder:GetChildren()) do
- if v:IsA("BillboardGui") then
- AnimateBillboard(v, true)
- end
- end
- end
- for i, v in pairs(Eggs:GetChildren()) do
- local EggChaos = ChaosFolder:FindFirstChild(v.Name)
- if EggChaos ~= nil then
- local BillboardTemplate = script.Template:Clone()
- local Container = BillboardTemplate:WaitForChild("Container")
- local MainFrame = Container:WaitForChild("MainFrame")
- local Template = MainFrame:WaitForChild("Template")
- local Display = Template:WaitForChild("Display")
- BillboardTemplate.Parent = EggBillboardsFolder
- BillboardTemplate.Name = v.Name
- BillboardTemplate.Adornee = v:WaitForChild("EggMesh")
- BillboardTemplate.Enabled = true
- local Chaos = {}
- for x, Chao in pairs(EggChaos:GetChildren()) do
- table.insert(Chaos, Chao.Rarity.Value)
- end
- table.sort(Chaos)
- for i = 1, math.floor(#Chaos / 2) do
- local j = #Chaos - i + 1
- Chaos[i], Chaos[j] = Chaos[j], Chaos[i]
- end
- for x, c in pairs(Chaos) do
- print(c)
- end
- for _, Rarity in pairs(Chaos) do
- for _, Chao in pairs(EggChaos:GetChildren()) do
- if Chao.Rarity.Value == Rarity then
- local Rarity = Chao.Rarity
- local ClonedTemplate = Template:Clone()
- ClonedTemplate.Name = Chao.Name
- ClonedTemplate.Rarity.Text = `{tostring(Chao.Rarity.Value)}%`
- ClonedTemplate.Visible = true
- ClonedTemplate.Parent = MainFrame
- local ChaoModel = Module3D:Attach3D(ClonedTemplate.Display, Chao:Clone())
- ChaoModel:SetDepthMultiplier(1.2)
- ChaoModel.Camera.FieldOfView = 5
- ChaoModel.Visible = true
- RunService.PreRender:Connect(function()
- ChaoModel:SetCFrame(CFrame.Angles(0, tick() * 2 % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
- end)
- break
- else
- continue
- end
- end
- RunService.PreRender:Connect(function()
- if Player:DistanceFromCharacter(v.EggMesh.PrimaryPart.Position) < MaxDisplayDistance then
- if CannotOpenBillboard == false then
- BillboardTemplate.Enabled = true
- AnimateBillboard(BillboardTemplate, true)
- end
- else
- if CannotOpenBillboard == false then
- AnimateBillboard(BillboardTemplate, false)
- end
- end
- end)
- end
- end
- end
- local function HatchOne(ChaoName, Egg)
- spawn(function()
- DisableAllBillboards()
- end)
- ToggleAllScreenGuis(false)
- workspace:WaitForChild("Camera").CameraType = Enum.CameraType.Scriptable
- TweenService:Create(workspace:WaitForChild("Camera"), TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {CFrame = Egg:FindFirstChild("CameraPart").CFrame}):Play()
- Gui.PetDisplay.PetName.Text = ChaoName
- local Chao = ChaosFolder:FindFirstChild(Egg.Name):FindFirstChild(ChaoName):Clone()
- IsHatching = true
- local EggMesh = Egg:FindFirstChild("EggMesh"):Clone()
- for i, v in pairs(EggMesh:GetChildren()) do
- if v:IsA("BasePart") then
- v.Anchored = true
- v.CanCollide = false
- end
- end
- HatchOneConnection = RunService.PreRender:Connect(function()
- local cframe = CFrame.new(0, 0, -EggMesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(0, 0, math.sin(time() * 18) / 2.3)
- EggMesh.PrimaryPart.CFrame = workspace.Camera.CFrame * cframe
- end)
- EggMesh.Parent = workspace.Camera
- task.wait(3)
- for i, v in pairs(EggMesh:GetChildren()) do
- if v:IsA("BasePart") then
- TweenService:Create(v, TweenInfo.new(0.5), {Transparency = 1}):Play()
- end
- end
- task.wait(0.5)
- HatchOneConnection:Disconnect()
- EggMesh:Destroy()
- Gui.PetDisplay.Visible = true
- local ChaoModel = Module3D:Attach3D(Gui.PetDisplay, Chao)
- ChaoModel:SetDepthMultiplier(1.2)
- ChaoModel.Camera.FieldOfView = 5
- ChaoModel.Visible = true
- RunService.PreRender:Connect(function()
- ChaoModel:SetCFrame(CFrame.Angles(0, tick() * 2 % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
- end)
- task.wait(3)
- TweenService:Create(Gui.PetDisplay:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
- task.wait(0.5)
- for i, v in pairs(Gui.PetDisplay:GetDescendants()) do
- if v:IsA("ViewportFrame") then
- v:Destroy()
- end
- end
- Gui.PetDisplay.Visible = false
- IsHatching = false
- spawn(function()
- EnableAllBillboards()
- end)
- ToggleAllScreenGuis(true)
- _G.NewTemplate(ChaoName)
- workspace:WaitForChild("Camera").CameraType = Enum.CameraType.Follow
- end
- local function TripleHatch(ChaoName, ChaoName2, ChaoName3, Egg)
- spawn(function()
- DisableAllBillboards()
- end)
- ToggleAllScreenGuis(false)
- workspace:WaitForChild("Camera").CameraType = Enum.CameraType.Scriptable
- TweenService:Create(workspace:WaitForChild("Camera"), TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {CFrame = Egg:FindFirstChild("CameraPart").CFrame}):Play()
- local Chao = ChaosFolder[Egg.Name]:FindFirstChild(ChaoName):Clone()
- local Chao2 = ChaosFolder[Egg.Name]:FindFirstChild(ChaoName2):Clone()
- local Chao3 = ChaosFolder[Egg.Name]:FindFirstChild(ChaoName3):Clone()
- Gui.PetDisplay.PetName.Text = ChaoName
- Gui.PetDisplay2.PetName.Text = ChaoName2
- Gui.PetDisplay3.PetName.Text = ChaoName3
- IsHatching = true
- local EggMesh = Egg:FindFirstChild("EggMesh"):Clone()
- local EggMesh2 = Egg:FindFirstChild("EggMesh"):Clone()
- local EggMesh3 = Egg:FindFirstChild("EggMesh"):Clone()
- for i, v in pairs(EggMesh:GetChildren()) do
- if v:IsA("BasePart") then
- v.Anchored = true
- v.CanCollide = false
- end
- end
- for i, v in pairs(EggMesh2:GetChildren()) do
- if v:IsA("BasePart") then
- v.Anchored = true
- v.CanCollide = false
- end
- end
- for i, v in pairs(EggMesh3:GetChildren()) do
- if v:IsA("BasePart") then
- v.Anchored = true
- v.CanCollide = false
- end
- end
- HatchOneConnection = RunService.PreRender:Connect(function()
- local cframe = CFrame.new(0, 0, -EggMesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(0, 0, math.sin(time() * 18) / 2.3)
- local cframe2 = CFrame.new(6, 0, -EggMesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(0, 0, math.sin(time() * 18) / 2.3)
- local cframe3 = CFrame.new(-6, 0, -EggMesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(0, 0, math.sin(time() * 18) / 2.3)
- EggMesh.PrimaryPart.CFrame = workspace.Camera.CFrame * cframe
- EggMesh2.PrimaryPart.CFrame = workspace.Camera.CFrame * cframe2
- EggMesh3.PrimaryPart.CFrame = workspace.Camera.CFrame * cframe3
- end)
- EggMesh.Parent = workspace.Camera
- EggMesh2.Parent = workspace.Camera
- EggMesh3.Parent = workspace.Camera
- task.wait(3)
- for i, v in pairs(EggMesh:GetChildren()) do
- if v:IsA("BasePart") then
- TweenService:Create(v, TweenInfo.new(0.5), {Transparency = 1}):Play()
- end
- end
- for i, v in pairs(EggMesh2:GetChildren()) do
- if v:IsA("BasePart") then
- TweenService:Create(v, TweenInfo.new(0.5), {Transparency = 1}):Play()
- end
- end
- for i, v in pairs(EggMesh3:GetChildren()) do
- if v:IsA("BasePart") then
- TweenService:Create(v, TweenInfo.new(0.5), {Transparency = 1}):Play()
- end
- end
- task.wait(0.5)
- HatchOneConnection:Disconnect()
- EggMesh:Destroy()
- EggMesh2:Destroy()
- EggMesh3:Destroy()
- Gui.PetDisplay.Visible = true
- Gui.PetDisplay2.Visible = true
- Gui.PetDisplay3.Visible = true
- local ChaoModel = Module3D:Attach3D(Gui.PetDisplay, Chao)
- ChaoModel:SetDepthMultiplier(1.2)
- ChaoModel.Camera.FieldOfView = 5
- ChaoModel.Visible = true
- local ChaoModel2 = Module3D:Attach3D(Gui.PetDisplay2, Chao2)
- ChaoModel2:SetDepthMultiplier(1.2)
- ChaoModel2.Camera.FieldOfView = 5
- ChaoModel2.Visible = true
- local ChaoModel3 = Module3D:Attach3D(Gui.PetDisplay3, Chao3)
- ChaoModel3:SetDepthMultiplier(1.2)
- ChaoModel3.Camera.FieldOfView = 5
- ChaoModel3.Visible = true
- RunService.PreRender:Connect(function()
- ChaoModel:SetCFrame(CFrame.Angles(0, tick() * 2 % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
- ChaoModel2:SetCFrame(CFrame.Angles(0, tick() * 2 % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
- ChaoModel3:SetCFrame(CFrame.Angles(0, tick() * 2 % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
- end)
- task.wait(3)
- TweenService:Create(Gui.PetDisplay:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
- TweenService:Create(Gui.PetDisplay2:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
- TweenService:Create(Gui.PetDisplay3:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
- task.wait(0.5)
- for i, v in pairs(Gui.PetDisplay:GetDescendants()) do
- if v:IsA("ViewportFrame") then
- v:Destroy()
- end
- end
- for i, v in pairs(Gui.PetDisplay2:GetDescendants()) do
- if v:IsA("ViewportFrame") then
- v:Destroy()
- end
- end
- for i, v in pairs(Gui.PetDisplay3:GetDescendants()) do
- if v:IsA("ViewportFrame") then
- v:Destroy()
- end
- end
- Gui.PetDisplay.Visible = false
- Gui.PetDisplay2.Visible = false
- Gui.PetDisplay3.Visible = false
- IsHatching = false
- spawn(function()
- EnableAllBillboards()
- end)
- ToggleAllScreenGuis(true)
- _G.NewTemplate(ChaoName)
- _G.NewTemplate(ChaoName2)
- _G.NewTemplate(ChaoName3)
- workspace:WaitForChild("Camera").CameraType = Enum.CameraType.Follow
- end
- UserInputService.InputBegan:Connect(function(Input: InputObject, GameProcessedEvent: boolean)
- if GameProcessedEvent then return end
- if Input.KeyCode == Enum.KeyCode.E then
- if Player.Character ~= nil and IsHatching == false then
- local NearestEgg
- local PlayerPosition = Player.Character:WaitForChild("HumanoidRootPart").Position
- for i, v in pairs(Eggs:GetChildren()) do
- if NearestEgg == nil then
- NearestEgg = v
- else
- if (PlayerPosition - v:WaitForChild("EggMesh").Position).Magnitude < (NearestEgg:WaitForChild("EggMesh").Position - PlayerPosition).Magnitude then
- NearestEgg = v
- end
- end
- end
- if Player:DistanceFromCharacter(NearestEgg.EggMesh.PrimaryPart.CFrame.Position) < MaxDisplayDistance then
- CanHatch = true
- else
- CanHatch = false
- end
- if CanHatch == true then
- local Result = ReplicatedStorage:WaitForChild("Remotes").Chaos.HatchServer:InvokeServer(NearestEgg)
- if Result ~= "Cannot Hatch" then
- if not Cooldown then
- Cooldown = true
- HatchOne(Result, NearestEgg)
- task.wait(0.1)
- Cooldown = false
- end
- else
- print("Cannot Hatch")
- end
- end
- end
- end
- if Input.KeyCode == Enum.KeyCode.R then
- if Player.Character ~= nil and IsHatching == false then
- local NearestEgg
- local PlayerPosition = Player.Character:WaitForChild("HumanoidRootPart").Position
- for i, v in pairs(Eggs:GetChildren()) do
- if NearestEgg == nil then
- NearestEgg = v
- else
- if (PlayerPosition - v:WaitForChild("EggMesh").Position).Magnitude < (NearestEgg:WaitForChild("EggMesh").Position - PlayerPosition).Magnitude then
- NearestEgg = v
- end
- end
- end
- if Player:DistanceFromCharacter(NearestEgg.EggMesh.PrimaryPart.CFrame.Position) < MaxDisplayDistance then
- CanHatch = true
- else
- CanHatch = false
- end
- if CanHatch == true then
- local Result1, Result2, Result3 = ReplicatedStorage:WaitForChild("Remotes").Chaos.Hatch3Chaos:InvokeServer(NearestEgg)
- if Result1 ~= "The Player Does Not Own The Gamepass" and Result2 ~= nil and Result3 ~= nil then
- if not Cooldown then
- Cooldown = true
- TripleHatch(Result1, Result2, Result3, NearestEgg)
- task.wait(0.1)
- Cooldown = false
- end
- elseif Result1 == "The Player Does Not Own The Gamepass" then
- MarketPlaceService:PromptGamePassPurchase(Player, 1209923362)
- end
- end
- end
- end
- end)
- for i, v in pairs(EggBillboardsFolder:GetChildren()) do
- local EButton = v.Container.Buttons.E
- local RButton = v.Container.Buttons.R
- EButton.MouseButton1Click:Connect(function()
- local NearestEgg
- local PlayerPosition = Player.Character:WaitForChild("HumanoidRootPart").Position
- for i, v in pairs(Eggs:GetChildren()) do
- if NearestEgg == nil then
- NearestEgg = v
- else
- if (PlayerPosition - v:WaitForChild("EggMesh").Position).Magnitude < (NearestEgg:WaitForChild("EggMesh").Position - PlayerPosition).Magnitude then
- NearestEgg = v
- end
- end
- end
- if Player:DistanceFromCharacter(NearestEgg.EggMesh.PrimaryPart.CFrame.Position) < MaxDisplayDistance then
- CanHatch = true
- else
- CanHatch = false
- end
- if CanHatch == true then
- local Result = ReplicatedStorage:WaitForChild("Remotes").Chaos.HatchServer:InvokeServer(NearestEgg)
- if Result ~= "Cannot Hatch" then
- if not Cooldown then
- Cooldown = true
- HatchOne(Result, NearestEgg)
- task.wait(0.1)
- Cooldown = false
- end
- else
- print("Cannot Hatch")
- end
- end
- end)
- RButton.MouseButton1Click:Connect(function()
- if Player.Character ~= nil and IsHatching == false then
- local NearestEgg
- local PlayerPosition = Player.Character:WaitForChild("HumanoidRootPart").Position
- for i, v in pairs(Eggs:GetChildren()) do
- if NearestEgg == nil then
- NearestEgg = v
- else
- if (PlayerPosition - v:WaitForChild("EggMesh").Position).Magnitude < (NearestEgg:WaitForChild("EggMesh").Position - PlayerPosition).Magnitude then
- NearestEgg = v
- end
- end
- end
- if Player:DistanceFromCharacter(NearestEgg.EggMesh.PrimaryPart.CFrame.Position) < MaxDisplayDistance then
- CanHatch = true
- else
- CanHatch = false
- end
- if CanHatch == true then
- local Result1, Result2, Result3 = ReplicatedStorage:WaitForChild("Remotes").Chaos.Hatch3Chaos:InvokeServer(NearestEgg)
- if Result1 ~= "The Player Does Not Own The Gamepass" and Result2 ~= nil and Result3 ~= nil then
- if not Cooldown then
- Cooldown = true
- TripleHatch(Result1, Result2, Result3, NearestEgg)
- task.wait(0.1)
- Cooldown = false
- end
- elseif Result1 == "The Player Does Not Own The Gamepass" then
- MarketPlaceService:PromptGamePassPurchase(Player, 1209923362)
- end
- end
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment