i am making pets and wrote

local petClone = pet:Clone()

this is my entire script local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera local studio = game.Workspace.Studio

game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(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

--By now the egg is huge

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

pet: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 = 1
studio.Egg.Size = Vector3.new(5, 6.4, 5)
petClone:Destroy()

end)

4 comments

0

when u post a question u can see there is a lua symbol at the top, if u click it it will make the amount of lines u choose into a code

0

this is so messy and u should fix it, also i see at the top it game.Workspace.Camera, u should use game.Workspace.CurrentCamera instead, about ur error idk

0

if it say it a nil value then ur pet is a nil value, and u can’t clone it. U should check if the pet is already loaded in when u clone it, also i don’t see the pet’s variable so u might want to paste the whole script into here

0

what tutorial should i use to make pets