Cat not cloning

Hello, devs today i am having an issue with cloning a pet cat. When the player clicks the Equip button on the inv the cat should clone into his character and then everybody in the server can see his cat including himself, but the cat is not cloning in his character I check the client and server side and there is no cat.
Here is a video

LOCAL SCRIPT
local Equip = script.Parent
local InvHandler = game.Players.LocalPlayer.PlayerGui.InventoryHandler 
local UpperInv = InvHandler.UpperInv
local MaxPetLimit = UpperInv.MaxPetLimit
local PetLimitText = MaxPetLimit.PetLimitText
local PetPreview = UpperInv.PetPreview
local PetPreviewFrame = PetPreview.PetPreviewFrame
local Im = PetPreviewFrame.PetPreviewImage
-- We just defined all the UI elements 

local ReplicatedStorage = game:GetService("ReplicatedStorage")

Equip.MouseButton1Click:Connect(function()
	
		if Im.Image =="rbxassetid://7620353586" then -- Check if its the cat or not
		
		-- added a Value to the max pet limits and make sure to put what pet it is and how much of that pet this will help determine deletions and what to keep
		local EquipPet = ReplicatedStorage:WaitForChild("EquipPet") -- check if the remote event is there or not
		while EquipPet == nil do wait() end
		
		EquipPet:FireServer()-- Equip pet is the Remote event
	print("The Event Fired ")
	
		end

	end)
	
	

SERVER SCRIPT
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")
local plr = game.Players.LocalPlayer
local char = game.plr.Character
local humRoot = char:FindFirstChild("HumanoidRootPart")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BasicEggPetFolder = ReplicatedStorage.BasicEggPetFolder
local Cat = BasicEggPetFolder.Cat
local Dog = BasicEggPetFolder.Dog
local Mouse = BasicEggPetFolder.Mouse
local Dragon = BasicEggPetFolder.Dragon
local GrassyCat = BasicEggPetFolder.GrassyCat
local TeaMonster = BasicEggPetFolder.TeaMonster






EquipPet.OnServerEvent:Connect(function()
	local Cat = BasicEggPetFolder.Cat
	local Clo1 = Cat:Clone()
	local StatsValue = Instance.new("StringValue")
	StatsValue.Parent = Clo1
	StatsValue.Value = "Equipped"
	local plr = game.Players.LocalPlayer
	local char = plr.Character
	Clo1.Parent = char
	print(Clo1)
end)

There is no errors in the output. The FireServer actually fire but I don’t know about the server script because the cat did not clone .

There is no local player on server, OnServerEvent returns the player who fired the remote you can cache it as the first parameter of the function and use it

1 Like

Ok I added player as the parameter I will see if it works now

I’m surprised there are no errors, but like @Votagz said, in the .OnServerEvent function, you can pass the player as the first parameter.

EquipPet.OnServerEvent:Connect(function(Player)
	local Cat = BasicEggPetFolder.Cat
	local Clo1 = Cat:Clone()
	local StatsValue = Instance.new("StringValue")
	StatsValue.Parent = Clo1
	StatsValue.Value = "Equipped"
	local char = Player.Character
	if char then
		Clo1.Parent = char
	end
	print(Clo1)
end)

Also, I don’t think in your LocalScript that while loop is necessary, :WaitForChild() will either wait for that object to appear and return it, or it will throw a Infinite Yield error. I would change that to:

local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")
if EquipPet then
    EquipPet:FireServer()
end
1 Like

Make sure the Archivable property of the Cat’s model is set to true (enabled). You can’t clone an unarchivable model.

The script works thank you so much

The error is now fixed and I just appreciate your help thank you!