local cost = 50

local petModule = require(game:GetService("ServerScriptService"):WaitForChild("PetModule")) script.Parent.ClickDetector.MouseClick:Connect(function(player) if player.leaderstats.Cash.Value >= cost then

	player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - cost
	
	local pet = petModule.chooseRandomPet()
	
	local petVal = Instance.new("StringValue")
	petVal.Name = pet.Name -- here!
	petVal.Parent = player.PetInventory
	game.ReplicatedStorage.HatchEgg:FireClient(player, pet)
end

end)

3 comments

0

Does petModule.chooseRandomPet() return an Instance?

0

petModule.chooseRandomPet() is possibly not returning anything

0

it is wierd because sometimes it works and sometimes it doesnt