First script:
local Workspace= game:GetService("Workspace")
local ReplicatedStorage= game:GetService("ReplicatedStorage")
local Players= game:GetService("Players")
local BuyEgg= ReplicatedStorage.Remotes.Shop.BuyEgg
local PetHatched= ReplicatedStorage.Remotes.Shop.PetHatched
local Player = Players.LocalPlayer
local TweenInfos = TweenInfo.new(2,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out,0,false,0)
local TweenService = game:GetService("TweenService")
local EggHatchFrame = game.StarterGui.ScreenGui.EggHatchFrame
local EggsFolder = Workspace.Eggs
local PetModels = ReplicatedStorage.Pets
local part = Workspace.Part
local EggConfig = require(ReplicatedStorage.Config.Eggs)
local template= script.Parent.Template
local function GetRarityColor(rarity: string)
print(rarity)
local color
if rarity == "Common" then
color= Color3.fromRGB(136, 136, 136)
elseif rarity == "Uncommon" then
color= Color3.fromRGB(83, 255, 97)
elseif rarity == "Rare" then
color= Color3.fromRGB(55, 98, 199)
elseif rarity == "Legendary" then
color= Color3.fromRGB(225, 244, 50)
end
return color
end
local function GetChanceColor(chance: number)
print(chance)
if chance <101 then
chance = Color3.fromRGB(255,255,255)
end
return chance
end
local function GenerateViewportFrame(viewportFrame:ViewportFrame, petModel:Model)
petModel:PivotTo(CFrame.new()*CFrame.Angles(0,math.rad(90),0))
petModel.Parent=viewportFrame
local camera = Instance.new("Camera",viewportFrame)
viewportFrame.CurrentCamera= camera
camera.CFrame = CFrame.new(Vector3.new(0,0,3),petModel.PrimaryPart.Position)
end
local function GeneratePet(container: Frame, petConfig: table)
print(petConfig)
local clone = container.template:Clone()
clone.Parent = container
clone.Name = petConfig.Name
clone.Visible = true
clone.ViewportFrame.PetName.Text =petConfig.Chance.."%"
clone.ViewportFrame.PetName.TextColor3 = GetChanceColor(petConfig.Chance)
clone.ViewportFrame.Rarity.Text = petConfig.Rarity
clone.ViewportFrame.Rarity.TextColor3 = GetRarityColor(petConfig.Rarity)
local petClone = PetModels[petConfig.Name]:Clone()
GenerateViewportFrame(clone.ViewportFrame,petClone)
end
local function GenerateBillBoardGui(eggModel:Instance,eggConfig: table)
print(eggConfig)
local Attachment = eggModel.Egg.Attachment
local Clone = template:Clone()
Clone.Parent = script.Parent
Clone.Adornee = Attachment
Clone.Name= eggModel.Name
for _,pet in ipairs(eggConfig.Pets) do
GeneratePet(Clone.Frame.Container, pet)
end
Clone.Frame.Buttons.Auto.MouseButton1Click:Connect(function()
--if not Players.gamepass.AutoHatch.Value then
-- Prompt them to the Purchase the Gamepass
--else
BuyEgg:FireServer(eggModel.Name,"Auto")
-- end
end)
Clone.Frame.Buttons.X1.MouseButton1Click:Connect(function()
BuyEgg:FireServer(eggModel.Name,"X1")
end)
Clone.Frame.Buttons.X3.MouseButton1Click:Connect(function()
-- if not Players.gamepass.X3GamePass.Value then
-- Prompt them to the Purchase the Gamepass
-- else
BuyEgg:FireServer(eggModel.Name,"X3")
-- end
end)
end
GenerateBillBoardGui(EggsFolder.Basic_Egg, EggConfig.Basic_Egg)
Second script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BuyEgg = ReplicatedStorage.Remotes.Shop.BuyEgg
local ReplicatedStorage= game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local TweenInfos = TweenInfo.new(2,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out,0,false,0)
local Megistus = TweenService:Create(script.Parent,TweenInfos,{Position = UDim2.fromScale(0.391, 0.5)})
local EggClone = workspace:WaitForChild("Egg"):Clone()
EggClone.Parent= script.Parent
local EggHatchCamera = Instance.new("Camera",script.Parent)
script.Parent.CurrentCamera = EggHatchCamera
EggHatchCamera.CFrame= CFrame.new(EggClone.Position+Vector3.new(0,0,3),EggClone.Position)
BuyEgg.OnClientEvent:Connect(function()
Megistus:Play()
end)