Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local camera = game.Workspace.Camera
- local Studio = game.Workspace.Studio
- local TweenService = game:GetService("TweenService")
- local template = script:WaitForChild("Template")
- local ScrollingFrame = script.Parent:WaitForChild("Pets"):WaitForChild("ScrollingFrame")
- local ButtonConnection = {}
- local function setTemplateEquipped(template)
- for i, v in pairs(ScrollingFrame:GetChildren()) do
- if v:FindFirstChild("Equipped") then
- v.Equipped.Text = "UNEQUIPPED"
- v.Equipped.TextColor3 = Color3.fromRGB(255,0,0)
- end
- end
- template.Equipped.Text = "EQUIPPED"
- template.Equipped.TextColor3 = Color3.fromRGB(0,255,0)
- end
- local function addToFrame(pet)
- local newTemplate = template:Clone()
- newTemplate.Name = pet.Name
- newTemplate.PetName.Text = pet.Name
- newTemplate.Parent = ScrollingFrame
- local newPet = pet:Clone()
- newPet.Parent = newTemplate.ViewPortFrame
- local camera = Instance.new("Camera")
- camera.CFrame = CFrame.new(newPet.PrimaryPart.Position + (newPet.PrimaryPart.CFrame.lookVector * 3),newPet.PrimaryPart.Position)
- camera.Parent = newTemplate.ViewPortFrame
- newTemplate.ViewPortFrame.CurrentCamera = camera
- ButtonConnection[#ButtonConnection+1] = newTemplate.MouseButton1Click:Connect(function()
- if newTemplate.Equipped.Text == "EQUIPPED" then
- game.ReplicatedStorage.UnEquipPet:FireServer()
- newTemplate.Equipped.Text = "UNEQUIPPED"
- newTemplate.Equipped.TextColor3 = Color3.fromRGB(255,0,0)
- else
- game.ReplicatedStorage.EquipPet:FireServer(pet.Name)
- setTemplateEquipped(newTemplate)
- end
- end)
- end
- game.ReplicatedStorage.SendData.OnClientEvent:Connect(function(petNames)
- print("Picked up on the client")
- for i, petName in pairs(petNames) do
- if game.ReplicatedStorage.Pets:FindFirstChild(petName) then
- addToFrame(game.ReplicatedStorage.Pets:FindFirstChild(petName))
- end
- end
- end)
- game.ReplicatedStorage.SetEquippedPet.OnClientEvent:Connect(function(petName)
- if ScrollingFrame:FindFirstChild(petName) then -- double check
- setTemplateEquipped(ScrollingFrame[petName])
- end
- end)
- game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(pet)
- addToFrame(pet)
- camera.CameraType = Enum.CameraType.Scriptable
- camera.CFrame = Studio.CamPart.CFrame
- wait(1.5)
- for i = 1, 50, 1 do
- Studio.Egg.Size = Studio.Egg.Size + Vector3.new(0.1,0.1,0.1)
- wait(0.01)
- end
- local explosion = Instance.new("Explosion")
- explosion.BlastRadius = 10
- explosion.BlastPressure = 0
- explosion.Position = Studio.Egg.Position
- explosion.ExplosionType = Enum.ExplosionType.NoCraters
- explosion.DestroyJointRadiusPercent = 0
- explosion.Parent = Studio.Egg
- Studio.Egg.Transparency = 1
- local petClone = pet:Clone()
- for i, v in pairs(petClone:GetChildren()) do
- if v:IsA("BasePart")then
- v.Anchored = true
- end
- end
- for i, v in pairs(Studio.Confetti:GetChildren()) do
- if v:IsA("ParticleEmitter")then
- v.Enabled = true
- end
- end
- petClone:SetPrimaryPartCFrame(CFrame.new(Studio.Egg.Position,Studio.CamPart.Position))
- petClone.Parent = Studio
- local tweenInfo = TweenInfo.new(
- 2,
- Enum.EasingStyle.Bounce,
- Enum.EasingDirection.Out,
- 0,
- false,
- 0
- )
- local tween = TweenService:Create(camera, tweenInfo, {CFrame = CFrame.new(petClone.PrimaryPart.Position + (petClone.PrimaryPart.CFrame.lookVector * 5) + Vector3.new(0,0.75,0),petClone.PrimaryPart.Position)})
- tween:Play()
- wait(5)
- for i, v in pairs(Studio.Confetti:GetChildren()) do
- if v:IsA("ParticleEmitter")then
- v.Enabled = false
- end
- end
- camera.CameraType = Enum.CameraType.Custom
- Studio.Egg.Transparency = 0
- Studio.Egg.Size = Vector3.new(3.767, 4.745, 3.766)
- petClone:Destroy()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement