Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TS = game:GetService("TweenService")
- local RS = game:GetService("ReplicatedStorage")
- local Library = RS:WaitForChild("PetLibrary")
- local Eggs = require(Library:WaitForChild("Config"))
- local Data = Eggs[script.Parent.Name]
- local Cost = Data["Cost"]
- local Pets = Data["Pets"]
- local Buy = script.Parent:WaitForChild("Buy")
- local RangePart = UnCommon.RangePartUnCommon
- local CostGUI = Buy:WaitForChild("Cost")
- local CostText = CostGUI:WaitForChild("TextLabel")
- local NamePlate = script.Parent:WaitForChild("NamePlate")
- local NameGUI = NamePlate:WaitForChild("Name")
- local NameText = NameGUI:WaitForChild("TextLabel")
- local Egg = script.Parent:WaitForChild("Egg")
- CostText.Text = "Cost: "..Cost.." PizzaCoins"
- NameText.Text = script.Parent.Name.." Egg"
- local function RotateTween(Obj, Rot)
- local TI = TweenInfo.new(.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
- local properties = {
- Rotation = Rot
- }
- local Tween = TS:Create(Obj, TI, properties)
- Tween:Play()
- end
- local TotalWeight = 0
- for i,v in pairs(Pets) do
- TotalWeight = TotalWeight + v[1]
- end
- local function ChoosePet()
- local Chance = math.random(1,TotalWeight)
- local Counter = 0
- for i,v in pairs(Pets) do
- Counter = Counter+v[1]
- if Chance <= Counter then
- return i
- end
- end
- end
- local function UnboxPet(Player)
- local PetInv = Player:WaitForChild("Pets")
- local PetChosen = ChoosePet()
- Library:WaitForChild(PetChosen):Clone().Parent = PetInv
- print(Player.Name.." Hatched a "..PetChosen)
- local Gui = Instance.new("ScreenGui")
- local viewport = Instance.new("ViewportFrame")
- viewport.Size = UDim2.new(1, 0, 1, 0)
- viewport.BackgroundTransparency = 1
- local EggClone = Egg:Clone()
- local Pos = EggClone.PrimaryPart.Position
- EggClone.Parent = viewport
- local Camera = Instance.new("Camera")
- Camera.Parent = viewport
- viewport.CurrentCamera = Camera
- viewport.Parent = Gui
- Camera.CFrame = CFrame.new(Vector3.new(Pos.X, Pos.Y, Pos.Z+5),Pos)
- Gui.Parent = Player.PlayerGui
- wait(1)
- for i = 1,5 do
- RotateTween(viewport,25)
- wait(.1)
- RotateTween(viewport,-25)
- wait(.1)
- end
- RotateTween(viewport,0)
- wait(.5)
- EggClone:Destroy()
- local PetClone = Library:WaitForChild(PetChosen):Clone()
- local HeadPos = PetClone.PrimaryPart.Position
- PetClone.Parent = viewport
- Camera.CFrame = CFrame.new(Vector3.new(HeadPos.X,HeadPos.Y,HeadPos.Z+10),HeadPos)
- wait(1)
- Gui:Destroy()
- end
- RangePart.Touched:Connect(function(hit)
- local H = hit.Parent:FindFirstChild("Humanoid")
- if H then
- local player = game.Players.LocalPlayer
- local Mouse = player:GetMouse()
- Mouse.KeyDown:Connect(function(key)
- if key == "e" then
- local Stats = Player:WaitForChild("leaderstats")
- local Coins = Stats:WaitForChild("PizzaCoins")
- if Coins.Value >= Cost then
- Coins.Value = Coins.Value - Cost
- UnboxPet(Player)
- end
- end
- end)
- end
- end)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement