Alrighty, so i am currently making a Egg Hatching system and when i try to clone my pet to the Egg position to show the player what they got, It doesn't show the pet! I dont know if i need to include my module script or not so that will be at the bottom:

--Local 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
	
	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()
	
	if petClone then
				for i, v in pairs(petClone:GetChildren()) do
		if v:IsA("BasePart") then
			v.Anchored = true
		end
	end
	petClone:SetPrimaryPartCFrame( CFrame.new(studio.Egg.Position,studio.CamPart.Position) )
	petClone.Parent = studio
	
	local tweenInfo = TweenInfo.new(
		2.5,
		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(3)
	
	camera.CameraType = Enum.CameraType.Custom
	studio.Egg.Transparency = 0
	studio.Egg.Size = Vector3.new(4.732, 6, 4.732)
	petClone:Destroy()
	
end
end)

Here is my Module

local petModule = {}

petModule.pets = {
	["Epic"] = {game.ReplicatedStorage.pets.LavaBird};
	["Rare"] = {game.ReplicatedStorage.pets.StereoPet};
	["Uncommon"] = {game.ReplicatedStorage.pets.DodgeBall};
	["Basic"] = {game.ReplicatedStorage.pets.BasicDoggo};
	
}

petModule.rarityTable = {
	
	["Epic"] = 4;
	["Rare"] = 16;
	["Uncommon"] = 30;
	["Common"] = 50;
	
}

petModule.chooseRandomPet = function()
	
	local randomNumber = math.random(1,100)
	
	local counter = 0
	
	for rarity, weight in pairs(petModule.rarityTable) do
		counter = counter + weight
		if randomNumber <= counter then
			
			local rarityTable = petModule.pets[rarity]
			local chosenPet = rarityTable[math.random(1, #rarityTable)]
			
			return chosenPet
		end
	end
end

return petModule

1 comment

0

what did the server pass as the "pet" variable to the RemoteEvent, a direct link to the object (ReplicatedStorage.pets.SomePet), or a clone of it (SomePet:Clone()) ?