So i suck with for iv and stuff and im tryna make 3x hatch so i got 3 eggs to show up and 3 pets but now i need the animations to work like my 1x hatch how it like tilts to the left and right then spins the pet in a 360 motion
Example: https://gyazo.com/a36900dbf0b354ca81d04550a266ef52
What i got:https://gyazo.com/d6aa923b191f9ed8658afebaf2d87dad
can someone please help im tryna make it work like hatch one so ill include that to
Script:
local Player = game:GetService("Players").LocalPlayer
local WorkSpace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local EggRemoteEvents = ReplicatedStorage:WaitForChild("EggRemoteEvents")
local Camera = WorkSpace.CurrentCamera
local Eggs = require(ReplicatedStorage:WaitForChild("Eggs"):WaitForChild("ModuleScript"))
local openBillboardUI = script.Parent.Parent:FindFirstChildOfClass("BillboardGui")
local container = openBillboardUI:WaitForChild("Container")
--[[local PetDisplay = script.Parent.Parent:WaitForChild("PetDisplay")
local PetDisplay2 = script.Parent.Parent:WaitForChild("PetDisplay2")
local PetDisplay3 = script.Parent.Parent:WaitForChild("PetDisplay3")]]
local GamePassService = game:GetService("GamePassService")
-- Function to check if the player has a specific game pass
local function hasGamePass(player, gamePassId)
return GamePassService:PlayerHasPass(player, gamePassId)
end
local hatchSpeed = 1.2
local hatchOneConnection = nil
local HatchThreeConnection = nil
-- Modify hatch speed based on game pass ownership
local function adjustHatchSpeed()
if hasGamePass(Player, 741822901) then
hatchSpeed = 4 -- or any other value you want for double hatch speed
else
hatchSpeed = 2 -- default hatch speed
end
end
local function hatchOneEgg(eggName, petName)
adjustHatchSpeed()
container.Visible = false
local Module = Eggs[eggName]
local Pets = Module["Pets"]
local PetDisplay = script.Parent.Parent:WaitForChild("PetDisplay"):Clone()
PetDisplay.Parent = script.Parent
PetDisplay:WaitForChild("UIScale").Scale = 0
Player.Character.PrimaryPart.Anchored = true
local EggMesh = ReplicatedStorage:WaitForChild("Eggs"):WaitForChild(eggName):Clone()
EggMesh.Parent = Camera
EggMesh.Transparency = 1
Camera.CameraType = Enum.CameraType.Scriptable
TweenService:Create(Camera, TweenInfo.new(0.35/hatchSpeed, Enum.EasingStyle.Back), {FieldOfView = 85}):Play()
TweenService:Create(EggMesh, TweenInfo.new(0.5/hatchSpeed), {Transparency = 0}):Play()
hatchOneConnection = RunService.RenderStepped:Connect(function()
local cf = CFrame.new(0,0,-EggMesh.Size.Z * 1.5) * CFrame.Angles(0,0,math.sin(time() * 18)/(2.3/hatchSpeed))
EggMesh.CFrame = (Camera.CFrame * cf)
end)
task.wait(4/hatchSpeed)
hatchOneConnection:Disconnect()
EggMesh:Destroy()
local petMesh = ReplicatedStorage:WaitForChild("Pets"):WaitForChild(petName):Clone()
petMesh.Parent = Camera
PetDisplay.Visible = true
PetDisplay:WaitForChild("PetNameDisplay").Text = petName
if petMesh:GetAttribute("Secret") == true then
PetDisplay:WaitForChild("PetRarityDisplay").TextColor3 = petMesh:GetAttribute("Rarity_Color")
PetDisplay:WaitForChild("PetRarityDisplay").Text = "Secret"
else
PetDisplay:WaitForChild("PetRarityDisplay").TextColor3 = petMesh:GetAttribute("Rarity_Color")
PetDisplay:WaitForChild("PetRarityDisplay").Text = tostring(petMesh:GetAttribute("Rarity_Name")).." ("..tostring(Pets[petName][2]).."%)"
end
local scalePetDisplay = TweenService:Create(PetDisplay:WaitForChild("UIScale"), TweenInfo.new(0.6/hatchSpeed, Enum.EasingStyle.Back), {
Scale = 1
})
scalePetDisplay:Play()
hatchOneConnection = RunService.RenderStepped:Connect(function()
local cf = CFrame.new(0,0,-petMesh.PrimaryPart.Size.Z * petMesh:GetAttribute("SizeHatch")) * CFrame.Angles((-0.05), ((1.5*hatchSpeed)*tick() * 2 % (math.pi * 2)), 0)
petMesh.PrimaryPart.CFrame = (Camera.CFrame * cf)
end)
task.wait(4/hatchSpeed)
hatchOneConnection:Disconnect()
local cf = CFrame.new(0,0,-petMesh.PrimaryPart.Size.Z * petMesh:GetAttribute("SizeHatch")) * CFrame.Angles(0, 160.25, 0)
TweenService:Create(petMesh.PrimaryPart, TweenInfo.new(0.75/hatchSpeed, Enum.EasingStyle.Back), {
CFrame = (Camera.CFrame * cf)
}):Play()
task.wait(1/hatchSpeed)
local hidePet = TweenService:Create(petMesh.PrimaryPart, TweenInfo.new(1.5/hatchSpeed), {
CFrame = petMesh.PrimaryPart.CFrame - Vector3.new(0,10,0)
})
local hidePetDisplay = TweenService:Create(PetDisplay, TweenInfo.new(0.75/hatchSpeed, Enum.EasingStyle.Back), {
Position = UDim2.new(0.5,0, 2,0)
})
hidePet:Play()
hidePetDisplay:Play()
hidePet.Completed:Connect(function()
petMesh:Destroy()
PetDisplay:Destroy()
Camera.CameraType = Enum.CameraType.Follow
TweenService:Create(Camera, TweenInfo.new(0.35/hatchSpeed, Enum.EasingStyle.Back), {FieldOfView = 70}):Play()
Player.Character.PrimaryPart.Anchored = false
container.Visible = true
end)
end
local function hatchThreeEgg(eggName, petName1, petName2, petName3)
adjustHatchSpeed()
container.Visible = false
local Module = Eggs[eggName]
local Pets = Module["Pets"]
local EggMesh1 = ReplicatedStorage:WaitForChild("Eggs"):WaitForChild(eggName):Clone()
local EggMesh2 = ReplicatedStorage:WaitForChild("Eggs"):WaitForChild(eggName):Clone()
local EggMesh3 = ReplicatedStorage:WaitForChild("Eggs"):WaitForChild(eggName):Clone()
local PetDisplay1 = script.Parent.Parent:WaitForChild("PetDisplay"):Clone()
local PetDisplay2 = script.Parent.Parent:WaitForChild("PetDisplay"):Clone()
local PetDisplay3 = script.Parent.Parent:WaitForChild("PetDisplay"):Clone()
PetDisplay1.Parent = script.Parent
PetDisplay2.Parent = script.Parent
PetDisplay3.Parent = script.Parent
local eggMeshes = {EggMesh1, EggMesh2, EggMesh3}
local petDisplays = {PetDisplay1, PetDisplay2, PetDisplay3}
for i = 1, 3 do
eggMeshes[i].Parent = Camera
eggMeshes[i].Transparency = 1
local cf = CFrame.new((i - 2) * 5, 0, -5) -- Adjust the position of each egg to be further back
TweenService:Create(eggMeshes[i], TweenInfo.new(0.75 / hatchSpeed, Enum.EasingStyle.Back), {
CFrame = (Camera.CFrame * cf) * CFrame.Angles(0, math.rad(90), 0) -- Rotate the eggs to face left initially
}):Play()
TweenService:Create(eggMeshes[i], TweenInfo.new(0.5), {Transparency = 0}):Play()
end
Camera.CameraType = Enum.CameraType.Scriptable
TweenService:Create(Camera, TweenInfo.new(0.35 / hatchSpeed, Enum.EasingStyle.Back), {FieldOfView = 85}):Play()
task.wait(4 / hatchSpeed)
for i = 1, 3 do
local cf = CFrame.new((i - 2) * 5, 0, -5) -- Adjust the position of each egg to be further back
TweenService:Create(eggMeshes[i], TweenInfo.new(0.75 / hatchSpeed, Enum.EasingStyle.Back), {
CFrame = (Camera.CFrame * cf)
}):Play()
end
task.wait(0.75 / hatchSpeed)
for i = 1, 3 do
eggMeshes[i]:Destroy()
end
local petMeshes = {}
local petNames = {petName1, petName2, petName3}
for i = 1, 3 do
petMeshes[i] = ReplicatedStorage:WaitForChild("Pets"):WaitForChild(petNames[i]):Clone()
petMeshes[i].Parent = Camera
petDisplays[i].Visible = true
petDisplays[i]:WaitForChild("PetNameDisplay").Text = petNames[i]
if petMeshes[i]:GetAttribute("Secret") == true then
petDisplays[i]:WaitForChild("PetRarityDisplay").TextColor3 = petMeshes[i]:GetAttribute("Rarity_Color")
petDisplays[i]:WaitForChild("PetRarityDisplay").Text = "Secret"
else
petDisplays[i]:WaitForChild("PetRarityDisplay").TextColor3 = petMeshes[i]:GetAttribute("Rarity_Color")
petDisplays[i]:WaitForChild("PetRarityDisplay").Text = tostring(petMeshes[i]:GetAttribute("Rarity_Name")).." ("..tostring(Pets[petNames[i]][2]).."%)"
end
local scalePetDisplay = TweenService:Create(petDisplays[i]:WaitForChild("UIScale"), TweenInfo.new(0.6 / hatchSpeed, Enum.EasingStyle.Back), {
Scale = 1
})
scalePetDisplay:Play()
-- Add shaking motion to each pet
local cf = CFrame.new((i - 2) * 5, 0, -5) -- Adjust the position of each pet to be further back
TweenService:Create(petMeshes[i].PrimaryPart, TweenInfo.new(0.75 / hatchSpeed, Enum.EasingStyle.Back), {
CFrame = (Camera.CFrame * cf) * CFrame.Angles(0, math.rad(20 * math.sin(tick() * 5)), 0) -- Add shaking motion
}):Play()
end
task.wait(1 / hatchSpeed)
for i = 1, 3 do
local hidePet = TweenService:Create(petMeshes[i].PrimaryPart, TweenInfo.new(1.5 / hatchSpeed), {
CFrame = petMeshes[i].PrimaryPart.CFrame - Vector3.new(0, 10, 0)
})
local hidePetDisplay = TweenService:Create(petDisplays[i], TweenInfo.new(0.75 / hatchSpeed, Enum.EasingStyle.Back), {
Position = UDim2.new(0.5, 0, 2, 0)
})
-- Add spinning motion to hidePet
hidePet:Play()
hidePetDisplay:Play()
hidePet.Completed:Connect(function()
petMeshes[i]:Destroy()
petDisplays[i]:Destroy()
Camera.CameraType = Enum.CameraType.Follow
TweenService:Create(Camera, TweenInfo.new(0.35 / hatchSpeed, Enum.EasingStyle.Back), {FieldOfView = 70}):Play()
Player.Character.PrimaryPart.Anchored = false
container.Visible = true
end)
end
end
EggRemoteEvents:WaitForChild("hatchOne").OnClientEvent:Connect(function(eggName, petName)
hatchOneEgg(eggName, petName)
end)
EggRemoteEvents:WaitForChild("hatchTriple").OnClientEvent:Connect(function(eggName, petName1, petName2, petName3)
hatchThreeEgg(eggName, petName1, petName2, petName3)
end)