Advertisement
Jackthehunter25

Untitled

Jan 24th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. local camera = game.Workspace.Camera
  2. local Studio = game.Workspace.Studio
  3. local TweenService = game:GetService("TweenService")
  4.  
  5. local template = script:WaitForChild("Template")
  6. local ScrollingFrame = script.Parent:WaitForChild("Pets"):WaitForChild("ScrollingFrame")
  7.  
  8. local ButtonConnection = {}
  9.  
  10. local function setTemplateEquipped(template)
  11.  
  12. for i, v in pairs(ScrollingFrame:GetChildren()) do
  13. if v:FindFirstChild("Equipped") then
  14. v.Equipped.Text = "UNEQUIPPED"
  15. v.Equipped.TextColor3 = Color3.fromRGB(255,0,0)
  16.  
  17. end
  18. end
  19.  
  20. template.Equipped.Text = "EQUIPPED"
  21. template.Equipped.TextColor3 = Color3.fromRGB(0,255,0)
  22.  
  23. end
  24.  
  25. local function addToFrame(pet)
  26.  
  27. local newTemplate = template:Clone()
  28. newTemplate.Name = pet.Name
  29. newTemplate.PetName.Text = pet.Name
  30. newTemplate.Parent = ScrollingFrame
  31.  
  32. local newPet = pet:Clone()
  33. newPet.Parent = newTemplate.ViewPortFrame
  34.  
  35.  
  36.  
  37. local camera = Instance.new("Camera")
  38. camera.CFrame = CFrame.new(newPet.PrimaryPart.Position + (newPet.PrimaryPart.CFrame.lookVector * 3),newPet.PrimaryPart.Position)
  39. camera.Parent = newTemplate.ViewPortFrame
  40.  
  41. newTemplate.ViewPortFrame.CurrentCamera = camera
  42.  
  43. ButtonConnection[#ButtonConnection+1] = newTemplate.MouseButton1Click:Connect(function()
  44. if newTemplate.Equipped.Text == "EQUIPPED" then
  45. game.ReplicatedStorage.UnEquipPet:FireServer()
  46. newTemplate.Equipped.Text = "UNEQUIPPED"
  47. newTemplate.Equipped.TextColor3 = Color3.fromRGB(255,0,0)
  48. else
  49.  
  50. game.ReplicatedStorage.EquipPet:FireServer(pet.Name)
  51. setTemplateEquipped(newTemplate)
  52.  
  53. end
  54.  
  55. end)
  56. end
  57.  
  58. game.ReplicatedStorage.SendData.OnClientEvent:Connect(function(petNames)
  59. print("Picked up on the client")
  60. for i, petName in pairs(petNames) do
  61. if game.ReplicatedStorage.Pets:FindFirstChild(petName) then
  62. addToFrame(game.ReplicatedStorage.Pets:FindFirstChild(petName))
  63. end
  64. end
  65. end)
  66.  
  67. game.ReplicatedStorage.SetEquippedPet.OnClientEvent:Connect(function(petName)
  68. if ScrollingFrame:FindFirstChild(petName) then -- double check
  69. setTemplateEquipped(ScrollingFrame[petName])
  70. end
  71. end)
  72.  
  73. game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(pet)
  74.  
  75. addToFrame(pet)
  76. camera.CameraType = Enum.CameraType.Scriptable
  77. camera.CFrame = Studio.CamPart.CFrame
  78.  
  79. wait(1.5)
  80.  
  81. for i = 1, 50, 1 do
  82. Studio.Egg.Size = Studio.Egg.Size + Vector3.new(0.1,0.1,0.1)
  83. wait(0.01)
  84. end
  85.  
  86. local explosion = Instance.new("Explosion")
  87. explosion.BlastRadius = 10
  88. explosion.BlastPressure = 0
  89. explosion.Position = Studio.Egg.Position
  90. explosion.ExplosionType = Enum.ExplosionType.NoCraters
  91. explosion.DestroyJointRadiusPercent = 0
  92.  
  93. explosion.Parent = Studio.Egg
  94.  
  95.  
  96. Studio.Egg.Transparency = 1
  97.  
  98. local petClone = pet:Clone()
  99.  
  100. for i, v in pairs(petClone:GetChildren()) do
  101. if v:IsA("BasePart")then
  102. v.Anchored = true
  103. end
  104. end
  105.  
  106. for i, v in pairs(Studio.Confetti:GetChildren()) do
  107. if v:IsA("ParticleEmitter")then
  108. v.Enabled = true
  109.  
  110. end
  111. end
  112.  
  113. petClone:SetPrimaryPartCFrame(CFrame.new(Studio.Egg.Position,Studio.CamPart.Position))
  114. petClone.Parent = Studio
  115.  
  116. local tweenInfo = TweenInfo.new(
  117. 2,
  118. Enum.EasingStyle.Bounce,
  119. Enum.EasingDirection.Out,
  120. 0,
  121. false,
  122. 0
  123. )
  124.  
  125. 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)})
  126.  
  127. tween:Play()
  128.  
  129. wait(5)
  130.  
  131. for i, v in pairs(Studio.Confetti:GetChildren()) do
  132. if v:IsA("ParticleEmitter")then
  133. v.Enabled = false
  134.  
  135. end
  136. end
  137.  
  138. camera.CameraType = Enum.CameraType.Custom
  139. Studio.Egg.Transparency = 0
  140. Studio.Egg.Size = Vector3.new(3.767, 4.745, 3.766)
  141. petClone:Destroy()
  142.  
  143. end)
  144.  
  145.  
  146.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement